mapbox / mapbox-maps-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and Metal
https://www.mapbox.com/mapbox-mobile-sdk
Other
476 stars 154 forks source link

Crash in mapbox::common::CleanupManager::cleanup() #2174

Open jumbopilot opened 5 months ago

jumbopilot commented 5 months ago

Environment

Observed behavior and steps to reproduce

Run mapbox map and dismiss/display the map multiple times over 30 minutes using same SwiftUI view.

Observed: crash logfile from device Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: FRONTBOARD 2343432205 <RBSTerminateContext| domain:10 code:0x8BADF00D explanation:[app:10815] failed to terminate gracefully after 5.0s ProcessVisibility: Unknown ProcessState: Running WatchdogEvent: process-exit WatchdogVisibility: Foreground WatchdogCPUStatistics: ( "Elapsed total CPU time (seconds): 18.700 (user 14.430, system 4.270), 61% CPU", "Elapsed application CPU time (seconds): 5.393, 17% CPU" ) reportType:CrashLog maxTerminationResistance:Interactive>

Triggered by Thread: 0

Kernel Triage: VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter

Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x1d3c651cc psynch_cvwait + 8 1 libsystem_pthread.dylib 0x1e7a126e4 _pthread_cond_wait + 1228 2 libc++.1.dylib 0x19b2a5504 std::__1::condition_variable::wait(std::1::unique_lock&) + 28 3 libc++.1.dylib 0x19b2a8ea4 std::1::assoc_sub_state::sub_wait(std::__1::unique_lock<std::1::mutex>&) + 56 4 libc++.1.dylib 0x19b2a8df4 std::1::assoc_sub_state::copy() + 56 5 libc++.1.dylib 0x19b2a9198 std::1::future::get() + 32 6 MapboxCommon 0x1049cfaf0 0x104860000 + 1506032 7 MapboxCommon 0x1049cf2bc 0x104860000 + 1503932 8 MapboxCommon 0x1049d0ed8 0x104860000 + 1511128 9 MapboxCommon 0x1049ccef0 0x104860000 + 1494768 10 MapboxCommon 0x1048bee20 mapbox::common::CleanupManager::cleanup() + 1364 11 CoreFoundation 0x18aed17b8 CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 128 12 CoreFoundation 0x18aed16e8 _CFXRegistrationPost_block_invoke + 88 13 CoreFoundation 0x18aed1630 _CFXRegistrationPost + 440 14 CoreFoundation 0x18aecfbf8 _CFXNotificationPost + 728 15 Foundation 0x189d5e574 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92 16 UIKitCore 0x18dfc646c -[UIApplication _terminateWithStatus:] + 232 17 UIKitCore 0x18d29f630 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 112 18 UIKitCore 0x18d8ac134 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 164 19 UIKitCore 0x18dfc1b34 -[UIApplication workspaceShouldExit:withTransitionContext:] + 164 20 FrontBoardServices 0x1a3ba03e8 63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2 + 72 21 FrontBoardServices 0x1a3b686cc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168 22 FrontBoardServices 0x1a3ba0388 63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke + 128 23 libdispatch.dylib 0x1044c27bc _dispatch_client_callout + 20 24 libdispatch.dylib 0x1044c61f0 _dispatch_block_invoke_direct + 300 25 FrontBoardServices 0x1a3b69d58 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 52 26 FrontBoardServices 0x1a3b69cd8 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240 27 FrontBoardServices 0x1a3b69bb0 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28 28 CoreFoundation 0x18aed6874 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 29 CoreFoundation 0x18aed6808 CFRunLoopDoSource0 + 176 30 CoreFoundation 0x18aed4338 CFRunLoopDoSources0 + 340 31 CoreFoundation 0x18aed34c4 __CFRunLoopRun + 828 32 CoreFoundation 0x18aed2d18 CFRunLoopRunSpecific + 608 33 GraphicsServices 0x1cfa461a8 GSEventRunModal + 164 34 UIKitCore 0x18d50f058 -[UIApplication _run] + 888 35 UIKitCore 0x18d5c304c UIApplicationMain + 340 36 SwiftUI 0x18f0babd4 0x18ecc8000 + 4139988 37 SwiftUI 0x18f06735c 0x18ecc8000 + 3797852 38 SwiftUI 0x18f073118 0x18ecc8000 + 3846424 39 AppName 0x10117075c static AppName.$main() + 40 40 AppName 0x101174548 main + 12 41 dyld 0x1ae917e4c start + 2240

Expected behavior

No crash in MapboxCommon mapbox::common::CleanupManager::cleanup()

Notes / preliminary analysis

Device CPU is already loaded at ~50% by the whole app operation.

Additional links and references

The app makes use of multiple

pjleonard37 commented 5 months ago

Hi @jumbopilot --

Thanks for sharing this report. I was able to investigate today for some time, but I have not been able to replicate this crash. Could you share a simple project which replicates the issue?

KaylaBrady commented 1 week ago

I am also seeing this crash occasionally, though with WatchdogVisibility: Background.

The way this issue presents itself is that when backgrounding the app then reopening it after a while, new tiles do not load. After force closing the app and re-opening, the map tiles load as expected and there is a popup that the app crashed (sharing the crash report directly via the popup doesn't include the below crash report, but it can be found in Settings > Analytics & Improvements > Analytics Data.

Crash Logs Hardware Model: iPhone14,5 Process: iosApp [2429] Path: /private/var/containers/Bundle/Application/FFCBA577-3CB7-4B13-B099-0C03129E1DCB/iosApp.app/iosApp Identifier: com.mbta.tid.mbtaapp.staging Version: 1.0.5 (953) AppStoreTools: 16A242d AppVariant: 1:iPhone14,5:18 Beta: YES Code Type: ARM-64 (Native) Role: Background Parent Process: launchd [1] Coalition: com.mbta.tid.mbtaapp.staging [552] Date/Time: 2024-10-07 16:59:57.1867 -0400 Launch Time: 2024-10-07 16:45:09.9167 -0400 OS Version: iPhone OS 18.0 (22A3354) Release Type: User Baseband Version: 4.02.05 Report Version: 104 Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: FRONTBOARD 2343432205 :2429] Failed to terminate gracefully after 5.0s ProcessVisibility: Unknown ProcessState: Running WatchdogEvent: process-exit WatchdogVisibility: Background WatchdogCPUStatistics: ( "Elapsed total CPU time (seconds): 6.550 (user 3.730, system 2.820), 18% CPU", "Elapsed application CPU time (seconds): 0.317, 1% CPU" ) reportType:CrashLog maxTerminationResistance:Interactive> Triggered by Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x1e0e0a030 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x218336a50 _pthread_cond_wait + 1204 2 libc++.1.dylib 0x1a150a584 std::__1::condition_variable::wait(std::__1::unique_lock&) + 28 3 libc++.1.dylib 0x1a150ad00 std::__1::__assoc_sub_state::__sub_wait(std::__1::unique_lock&) + 56 4 libc++.1.dylib 0x1a150ac50 std::__1::__assoc_sub_state::copy() + 56 5 libc++.1.dylib 0x1a150aff4 std::__1::future::get() + 32 6 MapboxCommon 0x103b03af0 0x103994000 + 1506032 7 MapboxCommon 0x103b032bc 0x103994000 + 1503932 8 MapboxCommon 0x103b04ed8 0x103994000 + 1511128 9 MapboxCommon 0x103b00ef0 0x103994000 + 1494768 10 MapboxCommon 0x1039f2e20 mapbox::common::CleanupManager::cleanup() + 1364 11 CoreFoundation 0x190fbf078 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 128 12 CoreFoundation 0x190fbefa8 ___CFXRegistrationPost_block_invoke + 88 13 CoreFoundation 0x190fbeef0 _CFXRegistrationPost + 436 14 CoreFoundation 0x190fbd4a4 _CFXNotificationPost + 728 15 Foundation 0x18fbcf884 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92 16 UIKitCore 0x194869dac -[UIApplication _terminateWithStatus:] + 232 17 UIKitCore 0x1938c2e9c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 112 18 UIKitCore 0x194091504 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 164 19 UIKitCore 0x194865508 -[UIApplication workspaceShouldExit:withTransitionContext:] + 164 20 FrontBoardServices 0x1aa4e3ff4 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2 + 72 21 FrontBoardServices 0x1aa4a3cfc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168 22 FrontBoardServices 0x1aa4e3f94 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke + 128 23 libdispatch.dylib 0x198c6a0d0 _dispatch_client_callout + 20 24 libdispatch.dylib 0x198c6db14 _dispatch_block_invoke_direct + 284 25 FrontBoardServices 0x1aa4a53b8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 52 26 FrontBoardServices 0x1aa4a5338 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240 27 FrontBoardServices 0x1aa4a5210 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28 28 CoreFoundation 0x190fc4088 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 29 CoreFoundation 0x190fc401c __CFRunLoopDoSource0 + 176 30 CoreFoundation 0x190fc1b6c __CFRunLoopDoSources0 + 344 31 CoreFoundation 0x190fc0d04 __CFRunLoopRun + 840 32 CoreFoundation 0x190fc05b8 CFRunLoopRunSpecific + 572 33 GraphicsServices 0x1dca561c4 GSEventRunModal + 164 34 UIKitCore 0x193b165f0 -[UIApplication _run] + 816 35 UIKitCore 0x193bc510c UIApplicationMain + 340 36 SwiftUI 0x19571f804 closure #1 in KitRendererCommon(_:) + 168 37 SwiftUI 0x1956fce68 runApp(_:) + 100 38 SwiftUI 0x1956ffd68 static App.main() + 180 39 iosApp 0x100bd6ff4 0x100b70000 + 421876 40 dyld 0x1b6793d34 start + 2724
aleksproger commented 1 week ago

Hey, @KaylaBrady thanks for sharing the crash log, which version of the SDK do you use?

KaylaBrady commented 1 week ago

@aleksproger this was using 11.3.0. I'm working on an upgrade to 11.7.0 to see if that will resolve the issue. With that upgrade I'm working through some new maps-core warnings after backgrounding ([Warning, maps-core]: {}[Style]: Required image 'image-name' is missing and it will not be rendered. Subscribe to StyleImageMissing event to be aware of the required missing images and add them by calling addStyleImage().). These images were previously retained after backgrounding, I'm not sure if this is related to the CleanupManager. I expect to be able to resolve these warnings but am wondering if there is a known related change that explains this behavior - nothing jumped out as me in the changelogs, and I'm having trouble finding documentation about the CleanupManager.

aleksproger commented 1 week ago

@KaylaBrady I suspect this problem happens when you delete annotation with image? If yes, then it's a known problem which actually shouldn't affect anything this is just incorrect log. If it's not your case please describe at which condition it happens. CleanupManager is basically an internal object and hence not documented and the warning is not related to this object.

KaylaBrady commented 1 week ago

@aleksproger this is happening occasionally after moving the app into the background for images that are used by a layer. The layer's source is not deleted when backgrounding.

We are are also noticing onStyleLoaded is being triggered after backgrounding the app which is we were not expecting. This is happening on 11.3.0 and 11.7.0 though, and may not be related to this original issue.