apache / cordova-ios

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

Port from ios@5 to ios@6.2.0 breaks Mapbox GJ call #1076

Closed NilsAtNK closed 2 years ago

NilsAtNK commented 3 years ago

Bug Report

Problem

We just ported our large React app from cordova-ios@5 to cordova-ios@6.2.0 and have the white screen of death. This has been debugged down to a call to MapBox GL which causes a restart and it enters an infinite loop. Reducing to minimum, we built the minimal Cordova tutorial hello app and embedded a minimal working Mapbox call (that is, a few lines in an index.html that works in Safari). I have exhausted answers I could find on Corodova docs, Stackoverflow and the interweb. Any help is welcome.

EDIT: Mapbox call works when on hardware, but not in simulator launched from Xcode

What is expected to happen?

Call to Mapbox works.

What does actually happen?

Call to Mapbox results in reset and white screen of death.

Information

The mini-app has CSP of: <meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; img-src data: blob: ;child-src blob: ;worker-src blob: ; connect-src https://*;">

In the working mini-app (non-Cordova), in the Chrome devtools Network tab there are successful requests to

Command or Code

Mini-app HTML Snippet (but full body)

    <script src="https://api.mapbox.com/mapbox-gl-js/v2.1.1/mapbox-gl.js"></script>
    <link href="https://api.mapbox.com/mapbox-gl-js/v2.1.1/mapbox-gl.css" rel="stylesheet" />

<body>
    <div id="map"></div>
    <script>
        mapboxgl.accessToken = 'put-token-here';
        var map = new mapboxgl.Map({
            container: 'map', // container id
            style: 'mapbox://styles/mapbox/streets-v11', // style URL
            center: [-74.5, 40], // starting position [lng, lat]
            zoom: 9 // starting zoom
        });
    </script>
</body>

When the mini-app is built as cordova-ios, the XCode console error (repeating over and over) is:

2021-02-17 18:11:28.003255-0500 HelloWorld[7294:213131] [ProcessSuspension] 0x102cb11c0 - ProcessAssertion: Failed to acquire RBS Background assertion 'ConnectionTerminationWatchdog' for process because PID is invalid
2021-02-17 18:11:28.003334-0500 HelloWorld[7294:213131] [Process] 0x141041818 - [pageProxyID=13, webPageID=14, PID=7306] WebPageProxy::processDidTerminate: (pid 7306), reason 3
2021-02-17 18:11:28.013004-0500 HelloWorld[7294:213131] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
2021-02-17 18:11:28.013054-0500 HelloWorld[7294:213131] [ProcessSuspension] 0x102cb1200 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 7306, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
2021-02-17 18:11:28.014918-0500 HelloWorld[7294:213131] [Loading] 0x141041818 - [pageProxyID=13, webPageID=14, PID=7306] WebPageProxy::dispatchProcessDidTerminate: reason = 3
2021-02-17 18:11:28.018405-0500 HelloWorld[7294:213131] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}>
2021-02-17 18:11:28.018495-0500 HelloWorld[7294:213131] [ProcessSuspension] 0x102cb12c0 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 7306, error: Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}

Environment, Platform, Device

Mac Mini, M1 processor, Rosetta2 Intel emulation
MacOS 11.0 Big Sur
XCode 12.4
XCode simulator iPhone 12 Pro Max (and others) 

Version information

Cordova 10.0.0
cordova-ios 6.2.0
node 14.15.4

Checklist

bndrgroup commented 3 years ago

+1 experiencing this same issue with Mapbox (only on simulator)

Liquid2Sky commented 3 years ago

I am dealing with the exact same issue at the moment. My Environment and the used Versions are (nearly) identical, we still use @mapbox-gl@1.12.0

Imho seems Mapbox to trigger the issue, however the root cause seems to be the Apple M1 My coworkers on Intel Macs don`t have this problem. Have you tried / can you try building your example on an Intel Mac?

Oh and this seems to be the issue in the Mapbox repo

NiklasMerz commented 2 years ago

Closing this as it seems this is a Mapbox issue and not a Cordova issue.