Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(iOS) App crashes in background EXC_BAD_ACCESS KERN_INVALID_ADDRESS #1103

Closed
olofho opened this issue Nov 7, 2020 · 18 comments
Closed

(iOS) App crashes in background EXC_BAD_ACCESS KERN_INVALID_ADDRESS #1103

olofho opened this issue Nov 7, 2020 · 18 comments

Comments

@olofho
Copy link

olofho commented Nov 7, 2020

Describe the bug
My application displays a lot of images on the map using <MapboxGL.Images /> and <MapboxGL.SymbolLayer />. When the application is running in the background and iOS tries to reduce the memory usage, the app crashes with the following stack:

Crashed: com.apple.main-thread
0  Mapbox                         0x102d87f58 mbgl::style::Style::Impl::removeImage(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 2581432
1  Mapbox                         0x102bcb4ac non-virtual thunk to mbgl::Map::Impl::onRemoveUnusedStyleImages(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 760076
2  Mapbox                         0x102c14f7c mbgl::ImageManager::reduceMemoryUse() + 1061852
3  Mapbox                         0x102c61b30 mbgl::RenderOrchestrator::reduceMemoryUse() + 1376144
4  Mapbox                         0x102c6b874 mbgl::Renderer::reduceMemoryUse() + 1416404
5  Mapbox                         0x102e6fbc4 -[MGLMapView pauseRendering:] + 30944
6  Mapbox                         0x102e6f924 -[MGLMapView didEnterBackground:] + 30272
7  CoreFoundation                 0x1a51bd764 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28
8  CoreFoundation                 0x1a51bd718 ___CFXRegistrationPost_block_invoke + 52
9  CoreFoundation                 0x1a51bccd4 _CFXRegistrationPost + 440
10 CoreFoundation                 0x1a51bc6a0 _CFXNotificationPost + 704
11 Foundation                     0x1a64545f4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
12 UIKitCore                      0x1a7b8cdac __47-[UIApplication _applicationDidEnterBackground]_block_invoke + 316
13 UIKitCore                      0x1a7493090 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 164
14 UIKitCore                      0x1a7b8cb44 -[UIApplication _applicationDidEnterBackground] + 144
15 UIKitCore                      0x1a7216640 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 + 904
16 UIKitCore                      0x1a77616ec _UIScenePerformActionsWithLifecycleActionMask + 112
17 UIKitCore                      0x1a7216220 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 224
18 UIKitCore                      0x1a7215cec -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 484
19 UIKitCore                      0x1a7216030 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 768
20 UIKitCore                      0x1a72158a8 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 340
21 UIKitCore                      0x1a721d9d8 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 196
22 UIKitCore                      0x1a7673dfc +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 892
23 UIKitCore                      0x1a7779a28 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 272
24 UIKitCore                      0x1a721d750 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 376
25 UIKitCore                      0x1a7052748 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 776
26 UIKitCore                      0x1a7051104 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 256
27 UIKitCore                      0x1a7052370 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 248
28 UIKitCore                      0x1a769c8f8 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 492
29 FrontBoardServices             0x1b4248b78 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 484
30 FrontBoardServices             0x1b4274194 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 152
31 FrontBoardServices             0x1b4256d24 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240
32 FrontBoardServices             0x1b42740c0 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke + 384
33 libdispatch.dylib              0x1a4e5cac8 _dispatch_client_callout + 20
34 libdispatch.dylib              0x1a4e60348 _dispatch_block_invoke_direct + 268
35 FrontBoardServices             0x1b429a0e0 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48
36 FrontBoardServices             0x1b4299d88 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 448
37 FrontBoardServices             0x1b429a2ac -[FBSSerialQueue _performNextFromRunLoopSource] + 32
38 CoreFoundation                 0x1a51db81c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
39 CoreFoundation                 0x1a51db718 __CFRunLoopDoSource0 + 208
40 CoreFoundation                 0x1a51daa28 __CFRunLoopDoSources0 + 268
41 CoreFoundation                 0x1a51d4d20 __CFRunLoopRun + 824
42 CoreFoundation                 0x1a51d44bc CFRunLoopRunSpecific + 600
43 GraphicsServices               0x1bbce6820 GSEventRunModal + 164
44 UIKitCore                      0x1a7b81164 -[UIApplication _run] + 1072
45 UIKitCore                      0x1a7b86840 UIApplicationMain + 168
46 App                       0x10217933c main + 7 (main.m:7)
47 libdyld.dylib                  0x1a4e9be40 start + 4

This started occuring when I upgraded to the 8.1.0.rc9 version, it does not happen on the 8.1.0-rc.4 version. The difference is that rc9 uses mapbox iOS SDK 5.8.0 and rc4 uses iOS SDK 5.9.0.

To Reproduce
Since this occurs when iOS tries to reduce memory usage by the application I am not sure what the easiest way to reproduce this is, other than displaying a bunch of images, starting another application and try to trigger iOS to reduce memory.

Expected behavior
The application should have its memory reduced without crashing.

Versions (please complete the following information):

  • Platform: iOS
  • Device: iPhone 11
  • Emulator/ Simulator: no
  • OS: iOS 14.1.0 (18A8395)
  • react-native-mapbox-gl Version 8.1.0.rc9
  • React Native Version 0.63.3

Additional context
The issue seems to be known and resolved in 5.9.0 with this PR: mapbox/mapbox-gl-native#16391 which is the reason why it doesnt crash in rc4 which uses that iOS SDK version. Having future versions of this SDK use iOS SDK >= 5.9.0 should fix this if my understanding of the issue is correct.

@ferdicus
Copy link
Member

ferdicus commented Nov 8, 2020

Did you try using a newer iOS SDK version?

@olofho
Copy link
Author

olofho commented Nov 9, 2020

I have tried rc4 = iOS 5.9.0 which does not crash and rc9 = iOS 5.8.0 which does crash. I have not tried any other iOS SDK.

@mzu
Copy link
Contributor

mzu commented Nov 9, 2020

I am seeing the same thing with rc9: crashlog.

@peterleng
Copy link

I am seeing the same thing with rc9

@ferdicus
Copy link
Member

ferdicus commented Nov 10, 2020

Please try with newer iOS SDKs and report back.
Current one is v6.2.1

Please check this ticket as a guide on how to increase iOS version

@mzu
Copy link
Contributor

mzu commented Nov 11, 2020

Added $ReactNativeMapboxGLIOSVersion = '~> 6.2.1' to /ios/Podfile

pod install produces following error:

[!] Error installing @react-native-mapbox-gl-mapbox-static
[!] /usr/bin/curl -f -L -o /var/folders/8g/hchxjm5j2_z7_0vvvj8t7db00000gn/T/d20201111-4396-12gkl8l/file.zip https://api.mapbox.com/downloads/v2/mobile-maps/releases/ios/6.2.1/mapbox-ios-sdk-dynamic-with-events.zip --create-dirs --netrc-optional --retry 2
...
curl: (22) The requested URL returned error: 401 Unauthorized

I have the access token set inside ~/.netrc according to mapbox docs.

Any ideas?

@SalihZinaty
Copy link

I'm facing the same problem when adding $ReactNativeMapboxGLIOSVersion = '~> 6.2.1'
I'm using react native 63.3 and Mapbox @react-native-mapbox-gl/maps": "^8.1.0-rc.9"

`[!] Error installing @react-native-mapbox-gl-mapbox-static
[!] /usr/bin/curl -f -L -o /var/folders/n5/33qj8l1n5lbfh700lfgbtk0r0000gn/T/d20201111-13256-1t84aqa/file.zip https://api.mapbox.com/downloads/v2/mobile-maps/releases/ios/6.2.1/mapbox-ios-sdk-dynamic-with-events.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.10.0 cocoapods-downloader/1.4.0'

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 401 Unauthorized`

@ferdicus
Copy link
Member

not sure, still looks like a credential setup issue
https://docs.mapbox.com/help/troubleshooting/ios-sdk-installation/#mapbox-maps-sdk
mapbox/mapbox-navigation-ios#2692

Maybe you have to cache bust pods or something? I'm no iOS guy, sorry

@rkrueger11
Copy link

rkrueger11 commented Nov 11, 2020

Also getting this issue... same versions of RN and RN-Mapbox-Gl/Maps.

Edit: Just saw that 6.3.0 was released yesterday too, tried that, but it wouldn't work because it didn't pass the max version allowed.

@rkrueger11
Copy link

Okay, might be a false alarm, I didn't have an ~/.netrc file saved. Sorry!

@SalihZinaty
Copy link

@rkrueger11
Can you tell me what to put inside this file and where to put it?
Thanks!

@ferdicus
Copy link
Member

@SalihZinaty, https://docs.mapbox.com/ios/maps/overview/#configure-credentials
See section Configure your secret token

@SalihZinaty
Copy link

SalihZinaty commented Nov 12, 2020

i got now
The requested URL returned error: 403 Forbidden
this is my .netrc file:
machine api.mapbox.com
login mapbox
password "My Token"

@janziemba
Copy link

@ferdicus Thank you, it works! Please do you know how to use it in continuous integration tool like Github Actions?

@SalihZinaty
Copy link

now it works for me, i had to add new TOKEN and give the DOWNLOADS:READ feature to the token

@mzu
Copy link
Contributor

mzu commented Nov 12, 2020

now it works for me, i had to add new TOKEN and give the DOWNLOADS:READ feature to the token

Works for me as well. Plus making sure that the .netrc file is in the home directory on your Mac. I had it in my project folder which was wrong.

@ferdicus
Copy link
Member

hey guys, would be nice if one of you, now that you successfully managed to upgrade, would add a little paragraph about it to the iOS installation guide 👍🏿

@ferdicus
Copy link
Member

Closing as resolved - use newer iOS sdk

mzu referenced this issue in mzu/maps Nov 13, 2020
Following ticket https://github.com/react-native-mapbox-gl/maps/issues/1103 to explain how to use a custom version of the Mapbox Maps SDK for iOS.
ferdicus referenced this issue Nov 20, 2020
* Update install.md

Following ticket https://github.com/react-native-mapbox-gl/maps/issues/1103 to explain how to use a custom version of the Mapbox Maps SDK for iOS.

* Update install.md

* Removed section for deprecated version
naftalibeder referenced this issue in TruckMap/maps Mar 22, 2021
* Update install.md

Following ticket https://github.com/react-native-mapbox-gl/maps/issues/1103 to explain how to use a custom version of the Mapbox Maps SDK for iOS.

* Update install.md

* Removed section for deprecated version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants