apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 986 forks source link

WKWebView crashes when doing async: false request #1024

Closed angjelkom closed 3 years ago

angjelkom commented 3 years ago

Bug Report

Problem

Doing non async ajax request causes a crash in the wkwebview: Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

Doing async ajax request works fine

What is expected to happen?

wkwebview doesn't crash and the ajax request succeeds

What does actually happen?

wkwebview crashes (causes sort of reload/restart of the wkwebview)

Information

in config.xml i included the needed preferences:

<preference name="scheme" value="app" /> <preference name="hostname" value="localhost" /> so my local files are loading (index.html, css, images, js and etc)

Command or Code

var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { console.log(this); }; xhttp.open('GET', './local-file.json', false); xhttp.send();

Environment, Platform, Device

Environment: iOS Platform: IOS Device: iPhone 5S

Version information

XCode: 12.2 Beta OS: BigSur 11.0 Beta Cordova CLI: 10.0 Platform: 6.1.0 cordova-plugin-device 2.0.3 "Device" cordova-plugin-dialogs 2.0.2 "Notification" cordova-plugin-splashscreen 6.0.0 "Splashscreen" cordova-plugin-whitelist 1.3.4 "Whitelist"

Checklist

breautek commented 3 years ago

Are you trying to use a synchronous XHR from the main thread? (ie outside of a web worker?).

If so, that's been deprecated by most browsers and doubt will be fixed if broken.

angjelkom commented 3 years ago

Are you trying to use a synchronous XHR from the main thread? (ie outside of a web worker?).

If so, that's been deprecated by most browsers and doubt will be fixed if broken.

indeed trying to do sync XHR from the main thread... tnx for letting me know

breautek commented 3 years ago

Thanks for clarifying.

For reference of the deprecation notice, you can view https://xhr.spec.whatwg.org/#the-open()-method

Synchronous XMLHttpRequest outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user’s experience. (This is a long process that takes many years.) Developers must not pass false for the async argument when current global object is a Window object. User agents are strongly encouraged to warn about such usage in developer tools and may experiment with throwing an "InvalidAccessError" DOMException when it occurs.

Apache Cordova makes an effort providing gaps in browsers by following the W3C spec. But the reason noted above, I don't think synchronous XHR will be addressed so I'll be closing this issue.

jcorriere-afs commented 3 years ago

@breautek Would you know if as of iOS 14.1 this is no longer supported by WKWebView ? App is only crashing on devices with 14.1 for us.

breautek commented 3 years ago

@breautek Would you know if as of iOS 14.1 this is no longer supported by WKWebView ? App is only crashing on devices with 14.1 for us.

Not sure. Synchronous XHR is something I never use in my projects.

jcorriere-afs commented 3 years ago

Thanks. We're using https://github.com/doedje/jquery.soap an older version but it "seems" like we are setting async properly.