Firebase-ios-sdk: Can't end BackgroundTask

Created on 26 Dec 2019  Â·  28Comments  Â·  Source: firebase/firebase-ios-sdk

Describe your environment

  • Xcode version: 11.3
  • Firebase SDK version: 6.14.0
  • Firebase Component: FirebaseAnalytics
  • Component version: 6.1.7

Describe the problem

Can't end BackgroundTask: no background task exists with identifier 32 (0x20), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

Steps to reproduce:

  1. Set symbolic breakpoint at UIApplicationEndBackgroundTaskError
  2. Lock simulator with Command-L
  3. Notice breakpoint hit

Relevant Code:

- (void)appWillBackground:(GDTCORApplication *)app {

is called twice, second time it causes the failure

GoogleDataTransport closed-by-bot

Most helpful comment

I just confirmed with Apple that the bug is fixed in iOS 13.4 beta 1
and updated Open Radar as Fixed:
http://openradar.appspot.com/radar?id=4974489829900288

iOS Simulator Version 11.4 (921.4)
SimulatorKit 581.7
CoreSimulator 704.8

Xcode Version 11.4 beta (11N111s)

And this issue is no longer reproducible for me on iOS 13.4 beta 1. Thank you

All 28 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

May be related to the radar that @mikehaney24 filed some time ago.

@paulz, can you share the stack trace at the symbolic breakpoint?

#0  0x00007fff480b1334 in UIApplicationEndBackgroundTaskError ()
#1  0x00007fff480b15d5 in -[UIApplication _endBackgroundTask:] ()
#2  0x000000010de75d48 in _dispatch_client_callout ()
#3  0x000000010de78cb9 in _dispatch_block_invoke_direct ()
#4  0x00007fff3662237e in __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ ()
#5  0x00007fff3662206c in -[FBSSerialQueue _queue_performNextIfPossible] ()
#6  0x00007fff3662257b in -[FBSSerialQueue _performNextFromRunLoopSource] ()
#7  0x00007fff23bd4471 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#8  0x00007fff23bd439c in __CFRunLoopDoSource0 ()
#9  0x00007fff23bd3b74 in __CFRunLoopDoSources0 ()
#10 0x00007fff23bce87f in __CFRunLoopRun ()
#11 0x00007fff23bce066 in CFRunLoopRunSpecific ()
#12 0x00007fff384c0bb0 in GSEventRunModal ()
#13 0x00007fff48092d4d in UIApplicationMain ()
#14 0x000000010cbccc5b in main at main.swift:3
#15 0x00007fff5227ec25 in start ()

If set breakpoint at endBackgroundTask I see it hit twice on lock with this stack:

#0  0x000000010ccbd226 in -[GDTCORApplication endBackgroundTask:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:133
#1  0x000000010ccc20de in __35-[GDTCORStorage appWillBackground:]_block_invoke at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:254
#2  0x000000010de74dd4 in _dispatch_call_block_and_release ()
#3  0x000000010de75d48 in _dispatch_client_callout ()
#4  0x000000010de7c5ef in _dispatch_lane_serial_drain ()
#5  0x000000010de7d17f in _dispatch_lane_invoke ()
#6  0x000000010de88a4e in _dispatch_workloop_worker_thread ()
#7  0x00007fff524636fc in _pthread_wqthread ()
#8  0x00007fff52462827 in start_wqthread ()

second time causing the the warning:

#0  0x000000010ccbd226 in -[GDTCORApplication endBackgroundTask:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:133
#1  0x000000010ccc20de in __35-[GDTCORStorage appWillBackground:]_block_invoke at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:254
#2  0x000000010de74dd4 in _dispatch_call_block_and_release ()
#3  0x000000010de75d48 in _dispatch_client_callout ()
#4  0x000000010de7c5ef in _dispatch_lane_serial_drain ()
#5  0x000000010de7d17f in _dispatch_lane_invoke ()
#6  0x000000010de88a4e in _dispatch_workloop_worker_thread ()
#7  0x00007fff524636fc in _pthread_wqthread ()
#8  0x00007fff52462827 in start_wqthread ()

And if you want to trace back when end background was dispatched:

Thread 65 Queue : com.google.GDTCORStorage (serial)
#0  0x000000010ccc1da4 in __35-[GDTCORStorage appWillBackground:]_block_invoke at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:231
#1  0x000000010de74dd4 in _dispatch_call_block_and_release ()
#2  0x000000010de75d48 in _dispatch_client_callout ()
#3  0x000000010de7c5ef in _dispatch_lane_serial_drain ()
#4  0x000000010de7d17f in _dispatch_lane_invoke ()
#5  0x000000010de88a4e in _dispatch_workloop_worker_thread ()
#6  0x00007fff524636fc in _pthread_wqthread ()
#7  0x00007fff52462827 in start_wqthread ()
Enqueued from com.apple.main-thread (Thread 1) Queue : com.apple.main-thread (serial)
#0  0x000000010de79c5d in dispatch_async ()
#1  0x000000010ccc1d3d in -[GDTCORStorage appWillBackground:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:231
#2  0x000000010ccbc352 in -[GDTCORLifecycle applicationDidEnterBackground:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORLifecycle.m:77
#3  0x00007fff23b9b5bc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#4  0x00007fff23b9aa35 in _CFXRegistrationPost1 ()
#5  0x00007fff23b9a7a1 in ___CFXNotificationPost_block_invoke ()
#6  0x00007fff23c988b3 in -[_CFXNotificationRegistrar find:object:observer:enumerator:] ()
#7  0x00007fff23b9a0f6 in _CFXNotificationPost ()
#8  0x00007fff2574bbf7 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#9  0x000000010ccbd531 in -[GDTCORApplication iOSApplicationDidEnterBackground:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:177
#10 0x00007fff23b9b5bc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#11 0x00007fff23b9aa35 in _CFXRegistrationPost1 ()
#12 0x00007fff23b9a7a1 in ___CFXNotificationPost_block_invoke ()
#13 0x00007fff23c988b3 in -[_CFXNotificationRegistrar find:object:observer:enumerator:] ()
#14 0x00007fff23b9a0f6 in _CFXNotificationPost ()
#15 0x00007fff2574bbf7 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#16 0x00007fff480980a9 in __47-[UIApplication _applicationDidEnterBackground]_block_invoke ()
#17 0x00007fff47a222b6 in +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] ()
#18 0x00007fff48097fa0 in -[UIApplication _applicationDidEnterBackground] ()
#19 0x00007fff477c6681 in __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 ()
#20 0x00007fff47cb44c1 in _UIScenePerformActionsWithLifecycleActionMask ()
#21 0x00007fff477c627f in __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke ()
#22 0x00007fff477c5d40 in -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] ()
#23 0x00007fff477c60ac in -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] ()
#24 0x00007fff477c5941 in -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] ()
#25 0x00007fff477c9f3f in __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 ()
#26 0x00007fff47bd8c83 in +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] ()
#27 0x00007fff47cd2dff in _UISceneSettingsDiffActionPerformChangesWithTransitionContext ()
#28 0x00007fff477c9c5a in __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke ()
#29 0x00007fff47cd2d02 in _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext ()
#30 0x00007fff477c9ac8 in -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] ()
#31 0x00007fff476206e7 in __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke ()
#32 0x00007fff4761f26c in -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] ()
#33 0x00007fff47620411 in -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] ()
#34 0x00007fff47bfac66 in -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] ()
#35 0x00007fff365d6c07 in -[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:] ()
#36 0x00007fff365fc99f in __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke_2 ()
#37 0x00007fff365e0c45 in -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] ()
#38 0x00007fff365fc8dc in __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke ()
#39 0x000000010de75d48 in _dispatch_client_callout ()
#40 0x000000010de78cb9 in _dispatch_block_invoke_direct ()
#41 0x00007fff3662237e in __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ ()
#42 0x00007fff3662206c in -[FBSSerialQueue _queue_performNextIfPossible] ()
#43 0x00007fff3662257b in -[FBSSerialQueue _performNextFromRunLoopSource] ()
#44 0x00007fff23bd4471 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#45 0x00007fff23bd439c in __CFRunLoopDoSource0 ()
#46 0x00007fff23bd3b74 in __CFRunLoopDoSources0 ()
#47 0x00007fff23bce87f in __CFRunLoopRun ()
#48 0x00007fff23bce066 in CFRunLoopRunSpecific ()
#49 0x00007fff384c0bb0 in GSEventRunModal ()
#50 0x00007fff48092d4d in UIApplicationMain ()
#51 0x000000010cbccc5b in main at .../RecordListen/main.swift:3
#52 0x00007fff5227ec25 in start ()

and previous call:

Thread 1 Queue : com.apple.main-thread (serial)
#0  0x000000010ccc1cce in -[GDTCORStorage appWillBackground:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:231
#1  0x000000010ccbc352 in -[GDTCORLifecycle applicationDidEnterBackground:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORLifecycle.m:77
#2  0x00007fff23b9b5bc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#3  0x00007fff23b9aa35 in _CFXRegistrationPost1 ()
#4  0x00007fff23b9a7a1 in ___CFXNotificationPost_block_invoke ()
#5  0x00007fff23c988b3 in -[_CFXNotificationRegistrar find:object:observer:enumerator:] ()
#6  0x00007fff23b9a0f6 in _CFXNotificationPost ()
#7  0x00007fff2574bbf7 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#8  0x000000010ccbd531 in -[GDTCORApplication iOSApplicationDidEnterBackground:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:177
#9  0x00007fff23b9b5bc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#10 0x00007fff23b9aa35 in _CFXRegistrationPost1 ()
#11 0x00007fff23b9a7a1 in ___CFXNotificationPost_block_invoke ()
#12 0x00007fff23c988b3 in -[_CFXNotificationRegistrar find:object:observer:enumerator:] ()
#13 0x00007fff23b9a0f6 in _CFXNotificationPost ()
#14 0x00007fff2574bbf7 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#15 0x00007fff480980a9 in __47-[UIApplication _applicationDidEnterBackground]_block_invoke ()
#16 0x00007fff47a222b6 in +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] ()
#17 0x00007fff48097fa0 in -[UIApplication _applicationDidEnterBackground] ()
#18 0x00007fff477c6681 in __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 ()
#19 0x00007fff47cb44c1 in _UIScenePerformActionsWithLifecycleActionMask ()
#20 0x00007fff477c627f in __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke ()
#21 0x00007fff477c5d40 in -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] ()
#22 0x00007fff477c60ac in -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] ()
#23 0x00007fff477c5941 in -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] ()
#24 0x00007fff477c9f3f in __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 ()
#25 0x00007fff47bd8c83 in +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] ()
#26 0x00007fff47cd2dff in _UISceneSettingsDiffActionPerformChangesWithTransitionContext ()
#27 0x00007fff477c9c5a in __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke ()
#28 0x00007fff47cd2d02 in _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext ()
#29 0x00007fff477c9ac8 in -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] ()
#30 0x00007fff476206e7 in __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke ()
#31 0x00007fff4761f26c in -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] ()
#32 0x00007fff47620411 in -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] ()
#33 0x00007fff47bfac66 in -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] ()
#34 0x00007fff365d6c07 in -[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:] ()
#35 0x00007fff365fc99f in __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke_2 ()
#36 0x00007fff365e0c45 in -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] ()
#37 0x00007fff365fc8dc in __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke ()
#38 0x000000010de75d48 in _dispatch_client_callout ()
#39 0x000000010de78cb9 in _dispatch_block_invoke_direct ()
#40 0x00007fff3662237e in __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ ()
#41 0x00007fff3662206c in -[FBSSerialQueue _queue_performNextIfPossible] ()
#42 0x00007fff3662257b in -[FBSSerialQueue _performNextFromRunLoopSource] ()
#43 0x00007fff23bd4471 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#44 0x00007fff23bd439c in __CFRunLoopDoSource0 ()
#45 0x00007fff23bd3b74 in __CFRunLoopDoSources0 ()
#46 0x00007fff23bce87f in __CFRunLoopRun ()
#47 0x00007fff23bce066 in CFRunLoopRunSpecific ()
#48 0x00007fff384c0bb0 in GSEventRunModal ()
#49 0x00007fff48092d4d in UIApplicationMain ()
#50 0x000000010cbccc5b in main at .../RecordListen/main.swift:3
#51 0x00007fff5227ec25 in start ()

Do you use scene delegates?

On Thu, Dec 26, 2019 at 1:31 PM Paul Zabelin notifications@github.com
wrote:

If set breakpoint at endBackgroundTask I see it hit twice on lock with
this stack:

0 0x000000010ccbd226 in -[GDTCORApplication endBackgroundTask:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:133

1 0x000000010ccc20de in __35-[GDTCORStorage appWillBackground:]_block_invoke at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:254

2 0x000000010de74dd4 in _dispatch_call_block_and_release ()

3 0x000000010de75d48 in _dispatch_client_callout ()

4 0x000000010de7c5ef in _dispatch_lane_serial_drain ()

5 0x000000010de7d17f in _dispatch_lane_invoke ()

6 0x000000010de88a4e in _dispatch_workloop_worker_thread ()

7 0x00007fff524636fc in _pthread_wqthread ()

8 0x00007fff52462827 in start_wqthread ()

second time causing the the warning:

0 0x000000010ccbd226 in -[GDTCORApplication endBackgroundTask:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:133

1 0x000000010ccc20de in __35-[GDTCORStorage appWillBackground:]_block_invoke at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:254

2 0x000000010de74dd4 in _dispatch_call_block_and_release ()

3 0x000000010de75d48 in _dispatch_client_callout ()

4 0x000000010de7c5ef in _dispatch_lane_serial_drain ()

5 0x000000010de7d17f in _dispatch_lane_invoke ()

6 0x000000010de88a4e in _dispatch_workloop_worker_thread ()

7 0x00007fff524636fc in _pthread_wqthread ()

8 0x00007fff52462827 in start_wqthread ()

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-ios-sdk/issues/4554?email_source=notifications&email_token=AAIILAV3YGOZEQB7NH5ALT3Q2UPCFA5CNFSM4J7HERW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHWFM2Q#issuecomment-569136746,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAIILAVNP7VKGMWXSOOXVR3Q2UPCFANCNFSM4J7HERWQ
.

Nope, regular storyboard app. Do you have an example app we can try?

Sent from my iPhone

On Dec 26, 2019, at 1:38 PM, Michael Haney notifications@github.com wrote:

Do you use scene delegates?

On Thu, Dec 26, 2019 at 1:31 PM Paul Zabelin notifications@github.com
wrote:

If set breakpoint at endBackgroundTask I see it hit twice on lock with
this stack:

0 0x000000010ccbd226 in -[GDTCORApplication endBackgroundTask:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:133

1 0x000000010ccc20de in __35-[GDTCORStorage appWillBackground:]_block_invoke at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:254

2 0x000000010de74dd4 in _dispatch_call_block_and_release ()

3 0x000000010de75d48 in _dispatch_client_callout ()

4 0x000000010de7c5ef in _dispatch_lane_serial_drain ()

5 0x000000010de7d17f in _dispatch_lane_invoke ()

6 0x000000010de88a4e in _dispatch_workloop_worker_thread ()

7 0x00007fff524636fc in _pthread_wqthread ()

8 0x00007fff52462827 in start_wqthread ()

second time causing the the warning:

0 0x000000010ccbd226 in -[GDTCORApplication endBackgroundTask:] at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m:133

1 0x000000010ccc20de in __35-[GDTCORStorage appWillBackground:]_block_invoke at .../Pods/GoogleDataTransport/GoogleDataTransport/GDTCORLibrary/GDTCORStorage.m:254

2 0x000000010de74dd4 in _dispatch_call_block_and_release ()

3 0x000000010de75d48 in _dispatch_client_callout ()

4 0x000000010de7c5ef in _dispatch_lane_serial_drain ()

5 0x000000010de7d17f in _dispatch_lane_invoke ()

6 0x000000010de88a4e in _dispatch_workloop_worker_thread ()

7 0x00007fff524636fc in _pthread_wqthread ()

8 0x00007fff52462827 in start_wqthread ()

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-ios-sdk/issues/4554?email_source=notifications&email_token=AAIILAV3YGOZEQB7NH5ALT3Q2UPCFA5CNFSM4J7HERW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHWFM2Q#issuecomment-569136746,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAIILAVNP7VKGMWXSOOXVR3Q2UPCFANCNFSM4J7HERWQ
.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

There is an app_spec in the podspec. If you've installed the newest versions of coocoapods and cocoapods-generate, you should be able to clone the repo and run GDT_DEV=1 pod gen GoogleDataTransportCCTSupport.podspec --auto-open --local-sources=. --gen-directory=gen/ --clean from the root repo directory and build and run the GDT CCT test app (image below). If you're able to repro in that environment, that'd be useful to know and make it a bit easier for me to test and prevent a future regression.

image

Thank you @mikehaney24
GDT_DEV=1 pod gen GoogleDataTransportCCTSupport.podspec --auto-open --local-sources=. --gen-directory=gen/ --clean failed for me with

[!] The platform of the target `App-watchOS` (watchOS 6.0) is not compatible with `GCDWebServer (3.5.3)`, which does not support `watchOS`.

Trying with --platforms=ios generated the workspace successfully:
GDT_DEV=1 pod gen GoogleDataTransportCCTSupport.podspec --auto-open --local-sources=. --gen-directory=gen/ --clean --platforms=ios

Able to reproduce the issue by pressing Cmd-L while the app is active in Simulator:

2020-01-01 22:53:18.661951-0800 GoogleDataTransportCCTSupport-TestApp[31014:13229601] Can't end BackgroundTask: no background task exists with identifier 3 (0x3), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

Locking simulator again causes the same warning:

2020-01-01 22:53:44.621220-0800 GoogleDataTransportCCTSupport-TestApp[31014:13229601] Can't end BackgroundTask: no background task exists with identifier 8 (0x8), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

It looks like the issue is reproducible consistently.

That isn't in itself damning--there's a bug in iOS 13 that causes that message (see image below). A completely empty new project will exhibit the same behavior. To determine if we have an unbalanced background task issue, you'd need to run on-device, open the device console in Xcode, filter on the app product name, and look for some logs that indicate a background task failure (most of ours have names, so that would tell us which one). This bug in iOS 13, consequently, makes it very difficult to determine if we really have an issue.

image


Hey @paulz. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!


Since there haven't been any recent updates here, I am going to close this issue.

@paulz if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

We are using Firebase for iOS (v6.15.0) and the issue is very easily reproducible.

2020-02-06 16:19:53.523648-0300CompanionApp[2685:789814] 6.15.0 - [Firebase/Core][I-COR000001] Configuring the default app.
2020-02-06 16:19:53.549861-0300 CompanionApp[2685:789813] 6.15.0 - [Firebase/Analytics][I-ACS024000] Debug mode is on

When user closes the app (app goes to background) the following log is visible:

2020-02-06 16:20:54.343516-0300 CompanionApp[2685:789833] 6.15.0 - [Firebase/Analytics][I-ACS023087] User property set. Name, value: lifetime_user_engagement (_lte), 570205
2020-02-06 16:20:54.343663-0300 CompanionApp[2685:789833] 6.15.0 - [Firebase/Analytics][I-ACS023087] User property set. Name, value: session_user_engagement (_se), 493714
2020-02-06 16:20:54.347284-0300 CompanionApp[2685:789833] 6.15.0 - [Firebase/Analytics][I-ACS012018] Saving bundle. size (bytes): 563
2020-02-06 16:20:54.347509-0300 CompanionApp[2685:789833] 6.15.0 - [Firebase/Analytics][I-ACS023116] Bundle added to the upload queue. BundleID, timestamp (ms): 20, 1581016854244
2020-02-06 16:20:54.352475-0300 CompanionApp[2685:789833] 6.15.0 - [Firebase/Analytics][I-ACS023039] Measurement data sent to network. Timestamp (ms), data: 1581016854352, <APMPBMeasurementBatch: 0x283aeb8d0>
2020-02-06 16:20:54.354004-0300 CompanionApp[2685:789833] 6.15.0 - [Firebase/Analytics][I-ACS900000] Uploading data. Host: https://app-measurement.com/a
2020-02-06 16:20:54.488361-0300 CompanionApp[2685:790068] 6.15.0 - [Firebase/Analytics][I-ACS901006] Received SSL challenge for host. Host: https://app-measurement.com/a
2020-02-06 16:20:54.655461-0300 CompanionApp[2685:789836] 6.15.0 - [Firebase/Analytics][I-ACS023044] Successful upload. Got network response. Code, size: 204, -1
2020-02-06 16:20:54.669121-0300 CompanionApp[2685:789836] 6.15.0 - [Firebase/Analytics][I-ACS002003] Measurement timer canceled
2020-02-06 16:20:54.669485-0300 CompanionApp[2685:790066] 6.15.0 - [Firebase/Analytics][I-ACS023142] Cancelling background upload task. Task ID : 11
2020-02-06 16:20:55.060146-0300 CompanionApp[2685:790068] [Answers] Finished transmission of '698A4D85-C13C-4C0D-9B66-XXXXXXXXXXXXX'.
2020-02-06 16:22:42.927589-0300 CompanionApp[2685:789606] Can't end BackgroundTask: no background task exists with identifier 14 (0xe), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

We (responsibly) use background tasks a lot on iOS 13 and have never seen this error in our code. Probably Firebase is storing background tasks identifiers which are not related to any task.

@rodmaz Do you have the same stack traces as above? What pods are you using?

We added Firebase manually, w/o CocoaPods. My guess Firebase Analytics is the culprit here.
I will try to post the stack trace later today.

Screen Shot 2020-02-07 at 10 40 52

My stack trace is identical to @paulz at https://github.com/firebase/firebase-ios-sdk/issues/4554#issuecomment-569135519.

Thread 1 Queue : com.apple.main-thread (serial)
#0  0x00000001c010ea34 in UIApplicationEndBackgroundTaskError ()
#1  0x00000001c010ed1c in -[UIApplication _endBackgroundTask:] ()
#2  0x00000001025f2bd8 in _dispatch_client_callout ()
#3  0x00000001025f5ffc in _dispatch_block_invoke_direct ()
#4  0x00000001c11e7418 in __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ ()
#5  0x00000001c11e70e4 in -[FBSSerialQueue _queue_performNextIfPossible] ()
#6  0x00000001c11e760c in -[FBSSerialQueue _performNextFromRunLoopSource] ()
#7  0x00000001bbfe8a00 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#8  0x00000001bbfe8958 in __CFRunLoopDoSource0 ()
#9  0x00000001bbfe80f0 in __CFRunLoopDoSources0 ()
#10 0x00000001bbfe323c in __CFRunLoopRun ()
#11 0x00000001bbfe2adc in CFRunLoopRunSpecific ()
#12 0x00000001c5f83328 in GSEventRunModal ()
#13 0x00000001c00f063c in UIApplicationMain ()
#14 0x0000000102243274 in main at CompanionApp/AppDelegate.swift:23
#15 0x00000001bbe6c360 in start ()

@mikehaney24 What's the right next step?

@rodmaz The debug message shows that Analytics tried to end a background task with the ID of 11 while the issue is with the task ID of 14 so I don't think Analytics is the issue here:

2020-02-06 16:20:54.669485-0300 CompanionApp[2685:790066] 6.15.0 - [Firebase/Analytics][I-ACS023142] Cancelling background upload task. Task ID : 11
2020-02-06 16:20:55.060146-0300 CompanionApp[2685:790068] [Answers] Finished transmission of '698A4D85-C13C-4C0D-9B66-XXXXXXXXXXXXX'.
2020-02-06 16:22:42.927589-0300 CompanionApp[2685:789606] Can't end BackgroundTask: no background task exists with identifier 14 (0xe), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

@baolocdo My gut feeling regarding analytics was due to the fact that the iOS warning message takes place right after the app moves to background. I am aware Firebase probably uses BG tasks elsewhere. Crashlytics perhaps?

The best bet is GoogleDataTransport which is a Firebase dependency

I don't use Pods and only have dependencies on FireStore, Auth, and FirebaseUI. One of these is the culprit.

Not wanting to add too much snark here, sure Firebase/Google has close enough ties with Apple to get help on this. At the very least, Firebase/Google could burn one developer ticket on this if it's too difficult to solve without under-the-covers help.

As I mentioned in a comment above this will happen even with an empty project. This is a problem in iOS (that's not to say that Firebase has no related issue, it would just be near-impossible to track down).

Here's a gif of me recreating the issue, no Firebase, no background tasks, nothing. This is a completely empty new project targeting iOS 13.2 in Xcode 11.2.1.
background

From my comment above:

To determine if we have an unbalanced background task issue, you'd need to run on-device, open the device console in Xcode, filter on the app product name, and look for some logs that indicate a background task failure (most of ours have names, so that would tell us which one). This bug in iOS 13, consequently, makes it very difficult to determine if we really have an issue.

All of GDT's background tasks are named, and they'd print their name out if they were the cause.

Filed a ~radar~ feedback to Apple (FB7568110).

Strangely enough, I am not seeing the Apple bug on an empty project.

@mikehaney24, could you please share the empty project where you see the issue without Firebase SDK?

Thank you!

I'm able to reproduce it in a new project with Xcode 11.1 (11A1027), iOS 13.1 simulator (SimulatorApp-912.1 SimulatorKit-570.3 CoreSimulator-681.17).

Steps to reproduce:

  1. Create a new single view application
  2. Run the application
  3. Background the app (Cmd+H)
  4. Stop and re-run the app
  5. Background the app again

This was the resulting log output:

2020-02-07 11:30:50.305835-0800 BGTaskTest[64114:1808974] Can't end BackgroundTask: no background task exists with identifier 2 (0x2), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

Great, thank you, @morganchen12, I also filed the feedback to Apple:

http://openradar.appspot.com/radar?id=4974489829900288

Just to add some information here, I comment out the code in Analytics to end background task, and the error still shows up. As @mikehaney24 's test, this seems to be an issue with the OS and the error message right after the Analytics message makes it look related. I found some related issue at https://github.com/flutter/flutter/issues/41095 as well. It does seem like an issue with iOS 13.

I just confirmed with Apple that the bug is fixed in iOS 13.4 beta 1
and updated Open Radar as Fixed:
http://openradar.appspot.com/radar?id=4974489829900288

iOS Simulator Version 11.4 (921.4)
SimulatorKit 581.7
CoreSimulator 704.8

Xcode Version 11.4 beta (11N111s)

And this issue is no longer reproducible for me on iOS 13.4 beta 1. Thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PierBover picture PierBover  Â·  3Comments

lorenzofiamingo picture lorenzofiamingo  Â·  3Comments

jaschaio picture jaschaio  Â·  3Comments

matthieuchappaz picture matthieuchappaz  Â·  3Comments

professorbk picture professorbk  Â·  3Comments