rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.21k stars 835 forks source link

[iOS] - [MGLMapView willResignActive:] #1068

Closed martinfrouin closed 3 years ago

martinfrouin commented 3 years ago

Describe the bug Some users of our app are getting this crash error since iOS 14:

Main Thread - Crashed

    libsystem_platform.dylib
    0x1f2c91000 + 22132
    AGXMetalA12
    0x1f3bf4000 + -2799427522815819632
    AppleMetalGLRenderer
    0x1f319c000 + 1520465701784075052
    GLEngine
    0x1dce67000 + -5304245852774968596
    GLKit
    0x1dbb42000 + -6543887488731973824
    Mapbox
    -[MGLMapView willResignActive:] MGLMapView.mm:1495
    CoreFoundation
    0x1ab621000 + 526180
    CoreFoundation
    0x1ab621000 + 5838652484339894040
    CoreFoundation
    0x1ab621000 + -8108640419370763052
    CoreFoundation
    0x1ab621000 + -7625419902370187616
    Foundation
    0x1ac92e000 + 7951885245622543860
    UIKitCore
    0x1ad4df000 + -7632541988927602764
    UIKitCore
    0x1ad4df000 + -6187282882493334224
    UIKitCore
    0x1ad4df000 + -3575670637391911724
    UIKitCore
    0x1ad4df000 + -6611242471535855424
    UIKitCore
    0x1ad4df000 + -4969389036777950324
    UIKitCore
    0x1ad4df000 + 4757859492272617168
    UIKitCore
    0x1ad4df000 + 8960513991027797832
    UIKitCore
    0x1ad4df000 + -4598902546484842376
    UIKitCore
    0x1ad4df000 + 3923654522725403688
    UIKitCore
    0x1ad4df000 + -2512790888762611696
    UIKitCore
    0x1ad4df000 + 8081208154016296432
    UIKitCore
    0x1ad4df000 + -9194013976881201488
    UIKitCore
    0x1ad4df000 + 5052451092944971884
    UIKitCore
    0x1ad4df000 + -7186500907876156712
    UIKitCore
    0x1ad4df000 + -494960552399235292
    FrontBoardServices
    0x1ba6eb000 + 6352875380952570744
    FrontBoardServices
    0x1ba6eb000 + -6162027100405280364
    FrontBoardServices
    0x1ba6eb000 + 6353825358999026980
    FrontBoardServices
    0x1ba6eb000 + 8890411328662098112
    libdispatch.dylib
    0x1ab33d000 + 8806018313671949000
    libdispatch.dylib
    0x1ab33d000 + -6975515621622516920
    FrontBoardServices
    0x1ba6eb000 + 963587251571634400
    FrontBoardServices
    0x1ba6eb000 + 4415812419985976712
    FrontBoardServices
    0x1ba6eb000 + -7682999677049523540
    CoreFoundation
    0x1ab621000 + 7232121294581000220
    CoreFoundation
    0x1ab621000 + 1250351978723796760
    CoreFoundation
    0x1ab621000 + 1538244804805778068
    CoreFoundation
    0x1ab621000 + 8594720766116330784
    CoreFoundation
    0x1ab621000 + -6018300039933627204
    GraphicsServices
    0x1c213a000 + -8199224784337225696
    UIKitCore
    0x1ad4df000 + 4567363605212157748
    UIKitCore
    0x1ad4df000 + -1341929202676912624
    <App Name>
    0x102c60000 + -6534630150582008972
    libdyld.dylib
    0x1ab37f000 + 3680

I don't have reproduce it yet but I saw a lot of threads about it like: https://github.com/mapbox/mapbox-gl-native-ios/issues/485

ferdicus commented 3 years ago

Thanks for reporting.

Did you try the solution mentioned in the upstream ticket? Did you try ios-sdk 6.2.1?

martinfrouin commented 3 years ago

I can't reproduced it yet so no, I haven't tried it

jaltin commented 3 years ago

We are also experiencing this crash at the moment.

It happens regularly when the app is in the background and alive (we are tracking movement so keeping the app alive). So far it has only happened when the app is in the background.

At the moment we can't reproduce it/trigger it.

I don't know if it will help, but I have added a screenshot from once when the crash happened while running from Xcode.

image

mfazekas commented 3 years ago

@jaltin thanks, what was the Mapbox IOS version?! Can you try with 6.3.0?!

There was some changes in that are in mapbox https://github.com/mapbox/mapbox-gl-native-ios/commit/21a7bbe970784ea4fa70a3f440e62a57b81d82cf

and according to this: https://github.com/mapbox/mapbox-gl-native-ios/issues/485#issuecomment-724362573 it's fixed.

martinfrouin commented 3 years ago

@jaltin thanks, what was the Mapbox IOS version?! Can you try with 6.3.0?!

There was some changes in that are in mapbox mapbox/mapbox-gl-native-ios@21a7bbe

and according to this: mapbox/mapbox-gl-native-ios#485 (comment) it's fixed.

@mfazekas how can I try with this version ? I don't see mapbox-gl-native-ios on the project or RN-mapbox dependencies or on the iOS files

mfazekas commented 3 years ago

@tinmar33 see https://github.com/react-native-mapbox-gl/maps/pull/940#issue-441493074

martinfrouin commented 3 years ago

@mfazekas [!] CocoaPods could not find compatible versions for pod "@react-native-mapbox-gl-mapbox-static": In Podfile: react-native-mapbox-gl (from '../node_modules/@react-native-mapbox-gl/maps') was resolved to 8.1.0-rc.9, which depends on @react-native-mapbox-gl-mapbox-static (~> 6.3)

After adding $ReactNativeMapboxGLIOSVersion = '~> 6.3' before use_native_modules!

I tried pod repo update but it doesn't fixed it

Any idea ?

mfazekas commented 3 years ago

@mfazekas [!] CocoaPods could not find compatible versions for pod "@react-native-mapbox-gl-mapbox-static": In Podfile: react-native-mapbox-gl (from '../node_modules/@react-native-mapbox-gl/maps') was resolved to 8.1.0-rc.9, which depends on @react-native-mapbox-gl-mapbox-static (~> 6.3)

After adding $ReactNativeMapboxGLIOSVersion = '~> 6.3' before use_native_modules!

I tried pod repo update but it doesn't fixed it

Any idea ?

@tinmar33 sorry I've just published 6.3.0 can you try

pod install --repo-update
martinfrouin commented 3 years ago

@mfazekas I have an error while downloading the package

Installing @react-native-mapbox-gl-mapbox-static (6.3.0) -> 401 Unauthorized

mfazekas commented 3 years ago

You'll need to set up .netrc see: https://github.com/react-native-mapbox-gl/maps/pull/1044#issue-493540536

martinfrouin commented 3 years ago

All good 👌 Thanks. I will try with this version

jaltin commented 3 years ago

@jaltin thanks, what was the Mapbox IOS version?! Can you try with 6.3.0?!

There was some changes in that are in mapbox mapbox/mapbox-gl-native-ios@21a7bbe

and according to this: mapbox/mapbox-gl-native-ios#485 (comment) it's fixed.

@mfazekas Thanks for your help! We are trying this right now and we will get back to you once we see if it works or not.

A related question: To use $ReactNativeMapboxGLIOSVersion has forced us to update to the 8.1.0.rc9 (we were on 8.0.0 before). Do you have any "feel" of how stable this version is? Is it close to a full release or still other known bugs?

ferdicus commented 3 years ago

@jaltin, version 8.1.0.rc9 is probably just as (un-)stable as 8.0.0. We don't have an official smoketest/ hardening/ testing cycle for our releases - it that's what you're asking.

jaltin commented 3 years ago

@ferdicus, thanks for your reply.

We are currently using 8.0.0 in prod, and I was asking because I wanted to get a feel if it will be reasonable to consider to use the rc9 release in our app in production to get around this bug. I was hoping that you guys would have a "feel" of the feasibility of this.

jaltin commented 3 years ago

@jaltin thanks, what was the Mapbox IOS version?! Can you try with 6.3.0?! There was some changes in that are in mapbox mapbox/mapbox-gl-native-ios@21a7bbe and according to this: mapbox/mapbox-gl-native-ios#485 (comment) it's fixed.

@mfazekas Thanks for your help! We are trying this right now and we will get back to you once we see if it works or not.

A related question: To use $ReactNativeMapboxGLIOSVersion has forced us to update to the 8.1.0.rc9 (we were on 8.0.0 before). Do you have any "feel" of how stable this version is? Is it close to a full release or still other known bugs?

Status update after our testing

So we have now tested this over the last 3 days running on 6 different devices (iPad and iPhone, iOS 12, 13 & 14) with the app running continuously in the background. None of the devices has crashed so setting the version of $ReactNativeMapboxGLIOSVersion to 6.3.0 seems to work for us so far.

Thanks a lot to @mfazekas and @ferdicus for your help!

ferdicus commented 3 years ago

good news 👍🏿

I'll close this ticket - feel free to open another one (or we can reopen this one) when this issue reoccurs

martinfrouin commented 3 years ago

I'm glad to hear it, thanks for the feedback @jaltin :)

luskin commented 3 years ago

@jaltin would you mind providing the community with some more details on how you got this working? We have added $ReactNativeMapboxGLIOSVersion = '~> 6.3' before use_native_modules! and have tried installing with repo update but cannot seem to get CocoaPods to adhere to the new version.

jaltin commented 3 years ago

@luskin I don't really know what could be going wrong for you. Did you set up .netrc on your machine too (https://docs.mapbox.com/ios/maps/guides/install/)?

luskin commented 3 years ago

@jaltin Turned out to be the lockfile which was restricting it. If anybody else is having problems upgrading to 6.3.0 remove any instances of MapBox in your Podfile.lock and run pod install --repo-update

RobertSasak commented 3 years ago

So far I can confirm that updating Mapbox to 6.2.1 did the trick. I have never experienced the crash myself but the crash has disapear from Crashlytics after updating to 6.2.1.

I use following script to add mapbox downloading crendentials to .netrc. appcenter-post-clone.sh

#!/usr/bin/env bash

# Add Mapbox password to .netrc in order to download iOS SDK
echo -e "machine $NETRC_MAPBOX_MACHINE\nlogin $NETRC_MAPBOX_LOGIN\npassword $NETRC_MAPBOX_PASSWORD" > ~/.netrc

So far I only updated to 6.2.1 as another bug in pod do not produce properly aligned archives for version 6.3.0 https://github.com/react-native-mapbox-gl/maps/issues/1097