[iOS 26.2] Crash due to WKScriptMessageHandler delegate

The crash is specific to iOS 26.2 WKScriptMessageHandler delegate func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage)

Name attribute is accessible but WKScriptMessage body attribute causes crash

The object seems to be not accessible

How exactly do you access the body attribute? And how exactly do you "post" messages to this handler in your JavaScript code? I do not see any issues in my App, which uses the script message handler extensively. So there doesn't seem to be a general problem here, but something specific of your code.

Yes, can you provide a short code listing showing how you are using this API?

This happens only in iOS 26.2 prior versions working fine . I’m listening for updates from sampleHandler triggered from web view. The object reference is released when the didReceive message is triggered

self.webkit.configuration.userContentController.add(self, name: "sampleHandler")

self.webkit.load(request)

func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {

print(message.name) // works print(message.body) // crashes

}

Same piece of code works in iOS 26.1 and earlier even a simple print crashes due to object no longer being available

[iOS 26.2] Crash due to WKScriptMessageHandler delegate
 
 
Q