[iOS 26.2] Crash due to WKScriptMessageHandler delegate

The crash is specific to iOS 26.2 prior versions working fine. 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(not in memory)

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

}

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. If you post the Feedback number here I'll check the status next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

Hi Vignesh107,

We have had the same problem and in our case, when JavaScript objects arrive in the WKScriptMessage content instead of pure JSON format, the system was able to interpret these objects and obtain the JSON in previous version of iOS 26.2, but not in iOS 26.2. After stringify it, we obtain the string that iOS 26.2 is able to process.

It sounds like you have found a workaround so perhaps a bug report is not necessary. If you are still having a problem with this API, please consider filing a feedback report and posting the feedback number to this thread.

Good morning, thank @DTS Engineer for your comment. The fact that we have been able to "solve" our problem does not mean that the logic of the system functions has changed since iOS 26.2. For this reason, we would like to know if this loss of functionality is going to be consolidated or if Apple will restore coverage in later versions of iOS. @DTS Engineer could you please give us an answer? Thanks.

[iOS 26.2] Crash due to WKScriptMessageHandler delegate
 
 
Q