apache / cordova-ios

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

iOS 15 Breaks with custom headers #1119

Closed BrainstemStudio closed 2 years ago

BrainstemStudio commented 3 years ago

Bug Report

We are busy reviewing our apps to get ready for iOS 15 changes. We have noticed when using a basic JS fetch and supplying custom headers the encounters an error. This is problematic especially if the the fetches require headers such as tokens, authorization ect.

This appears to only occur when using the scheme and host name options.

<preference name="scheme" value="http" />
<preference name="hostname" value="localhost" />

Problem

Web Error Failed to load resource: WebKit encountered an internal error

XCode Error

[Process] 0x128ad1000 - NetworkProcessProxy::didClose (Network Process 0 crash)
[assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}>

What is expected to happen?

At least a success or catch error should return on the js fetch

What does actually happen?

Xcode returns a error and the fetch does not execute

Information

We have tested a simple fetches, one without custom headers and one with custom headers. We also setup a minimal app without any plugins to isolate the issue. This issue does seem to originate from CDVWebViewEngine when scheme and hostname are used.

This all still works on iOS 14.6, so it appears to be something on iOS 15.0 that has changed.

Command or Code

What works

fetch(`https://everydaydigital.co.za/lab/tests/test.php`).then(r => {
    return r.json();
}).then(response => {
    console.log(response);
}).catch(err => {
    console.warn(err);
});

What doesn't work

fetch(`https://everydaydigital.co.za/lab/tests/test.php`,{
    headers : {
        'token' : '123456789'
    }
}).then(r => {
     return r.json();
}).then(response => {
    console.log(response);
}).catch(err => {
   console.warn(err);
});

Environment, Platform, Device

Mac OS XCode 13 Simulator

Version information

Cordova 10.0 Cordova iOS 6.2.0

Checklist

timbru31 commented 3 years ago

This probably should be reported to Apple (Feedback App) and/or the WebKit team (https://bugs.webkit.org)

NiklasMerz commented 3 years ago

Probably like the issue that I filed https://bugs.webkit.org/show_bug.cgi?id=226769

timbru31 commented 3 years ago

Which is hopefully fixed in beta 2 and/or public beta 1.

BrainstemStudio commented 3 years ago

Great to know. Thanks.

idoodler commented 3 years ago

The Bug Report indicates that it has been fixed and is available in iOS 15 Beta 2, I checked with the second Beta 2 today and I still have the same issue. Can anyone confirm this?

NiklasMerz commented 3 years ago

The CORS error I reported is fixed. My app works with the latest beta.

NiklasMerz commented 3 years ago

I just updated to the latest beta and it's broken again unfortunately. I commented on the WebKit bug again.

Let's hope the next betas are working again.

jesusfloresivelopment commented 3 years ago

Hi guys, I have the same problem, do you have any solution?

NiklasMerz commented 3 years ago

We need to wait until Apple releases a fixed version.

BrainstemStudio commented 2 years ago

@NiklasMerz I see this is been fixed in the latest beta release. I can confirm that custom headers work based on my reported example. I can further confirm that our cordova apps are working when run from xcode 13 / iOS 15 beta 4.