stephan-tolksdorf / STULabel

A faster and more flexible label view for iOS
Other
121 stars 28 forks source link

Crash on removeContentCGImagesOfLabelLayersWithoutWindow #10

Open Fabezi opened 4 years ago

Fabezi commented 4 years ago

Hey! We've been testing this framework on a few text-heavy screen for a while now without any issues, however, on our last update, we seem to have introduced this type of crash for a decent number of users. Haven't been able to reproduce this myself yet but will update this thread if I do.

Update: Seems to be related to the STUBackgroundAttribute and happens only on release builds.

#0. Crashed: com.apple.main-thread
0  STULabel                       0x101e6cde0 stu_label::LabelLayer::removeContentCGImagesOfLabelLayersWithoutWindow() + 1722 (STULabelLayer.mm:1722)
1  Foundation                     0x182975b64 -[__NSObserver _doit:] + 316
2  CoreFoundation                 0x1825f2288 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
3  CoreFoundation                 0x1825f22d0 ___CFXRegistrationPost1_block_invoke + 64
4  CoreFoundation                 0x1825f1630 _CFXRegistrationPost1 + 368
5  CoreFoundation                 0x1825f12e8 ___CFXNotificationPost_block_invoke + 104
6  CoreFoundation                 0x18256d59c -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1416
7  CoreFoundation                 0x1825f0c38 _CFXNotificationPost + 1244
8  Foundation                     0x18294d0c8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
9  UIKitCore                      0x186721ec4 __47-[UIApplication _applicationDidEnterBackground]_block_invoke + 312
10 UIKitCore                      0x18610f154 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 168
11 UIKitCore                      0x186721c80 -[UIApplication _applicationDidEnterBackground] + 116
12 UIKitCore                      0x185ee80e4 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 + 856
13 UIKitCore                      0x18637d698 _UIScenePerformActionsWithLifecycleActionMask + 100
14 UIKitCore                      0x185ee7cf0 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 196
15 UIKitCore                      0x185ee7748 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 296
16 UIKitCore                      0x185ee7b1c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 736
17 UIKitCore                      0x185ee73d8 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 336
18 UIKitCore                      0x185eeb8c4 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 188
19 UIKitCore                      0x1862aef08 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 824
20 UIKitCore                      0x186396c84 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244
21 UIKitCore                      0x185eeb5fc __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 136
22 UIKitCore                      0x186396b80 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 100
23 UIKitCore                      0x185eeb468 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 376
24 UIKitCore                      0x185d5d2c0 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 636
25 UIKitCore                      0x185d5be28 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 248
26 UIKitCore                      0x185d5cff8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220
27 UIKitCore                      0x1862cfd70 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464
28 FrontBoardServices             0x1877ca248 -[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:] + 544
29 FrontBoardServices             0x1877eed28 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke_2 + 120
30 FrontBoardServices             0x1877d3f04 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
31 FrontBoardServices             0x1877eec5c __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke + 184
32 libdispatch.dylib              0x182363184 _dispatch_client_callout + 16
33 libdispatch.dylib              0x18230bfd8 _dispatch_block_invoke_direct$VARIANT$mp + 224
34 FrontBoardServices             0x187813418 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
35 FrontBoardServices             0x1878130e4 -[FBSSerialQueue _queue_performNextIfPossible] + 404
36 FrontBoardServices             0x18781360c -[FBSSerialQueue _performNextFromRunLoopSource] + 28
37 CoreFoundation                 0x182614a00 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
38 CoreFoundation                 0x182614958 __CFRunLoopDoSource0 + 80
39 CoreFoundation                 0x1826140f0 __CFRunLoopDoSources0 + 180
40 CoreFoundation                 0x18260f23c __CFRunLoopRun + 1080
41 CoreFoundation                 0x18260eadc CFRunLoopRunSpecific + 464
42 GraphicsServices               0x18c5af328 GSEventRunModal + 104
43 UIKitCore                      0x18671c63c UIApplicationMain + 1936
stephan-tolksdorf commented 4 years ago

Thanks for reporting this issue!

The stack trace indicates that this crash happens when the app enters the background and removeContentCGImagesOfLabelLayersWithoutWindow is called in the UIApplicationDidEnterBackgroundNotification handler. Hence, to reproduce this, you may have to bring the application into the right state and then leave the app. If you can reproduce your issue, you could put a breakpoint at the beginning of the removeContentCGImagesOfLabelLayersWithoutWindow and see if you can figure out what's wrong, or maybe you find a way to reproduce the issue in the STULabel Demo app.

In order to be able to fix this issue I need more information or a way to reproduce the crash.