Issue Summary:
I have encountered an issue where JavaScript does not execute in a WebView when another UIViewController is presented modally with modalPresentationStyle.fullScreen. This problem only occurs on physical devices running iOS 17.5.1. The issue is not present on iOS 17.5 simulators or devices running iOS 17.4.1 or earlier.
Reproduction Steps:
- Create a ViewController with a WebView.
- Load a web page (e.g., https://apple.com) in the WebView.
- Present another ViewController modally with
modalPresentationStyle.fullScreen. - Verify that JavaScript execution in the initial WebView stops working.
Test Code:
import UIKit
import WebKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Set up the WebView
let configuration = WKWebViewConfiguration()
let webView = WKWebView(frame: view.frame, configuration: configuration)
view.addSubview(webView)
webView.frame = view.frame
if #available(iOS 16.4, *) {
webView.isInspectable = true
} else {
// Fallback on earlier versions
}
webView.load(URLRequest(url: URL(string: "https://apple.com")!))
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let navigationController = UINavigationController(rootViewController: TargetViewController())
navigationController.modalPresentationStyle = .fullScreen
present(navigationController, animated: true)
}
}
class TargetViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Set up the WebView
let webView = WKWebView(frame: view.frame, configuration: WKWebViewConfiguration())
view.addSubview(webView)
webView.frame = view.frame
if #available(iOS 16.4, *) {
webView.isInspectable = true
} else {
// Fallback on earlier versions
}
webView.load(URLRequest(url: URL(string: "https://apple.com")!))
}
}
Observations:
- The JavaScript within the WebView stops executing only on physical devices running iOS 17.5.1.
- This issue does not occur on the iOS 17.5 simulator.
- Devices running iOS 17.4.1 or earlier do not experience this issue.
Request for Assistance:
Could you please provide any insights or potential workarounds for this issue? Additionally, if this is a known bug, any information on upcoming fixes would be highly appreciated.
Thank you.