Skip to content

CPU_Resource issue when app is backgrounded #8239

Open
@punkrawktex

Description

[REQUIRED] Step 1: Describe your environment

  • Xcode version: _12.5
  • Firebase SDK version: 8.1.0_
  • Installation method: CocoaPods (select one)
  • Firebase Component: (Auth, Core, Database, Messaging, Storage, Analytics)

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

When users background our app Firebase is consuming more than 80% of the CPU for more than 40 seconds causing Apple to kill the app.
What happened? How can we make the problem occur?

We also use the Intercom SDK and this is causing the Intercom SDK to crash.

Relevant Code:

Stack trace:
{"app_name":"V1 Game","timestamp":"2021-06-07 13:25:34.00 -0700","app_version":"2.10.5","slice_uuid":"92B8550F-24FA-3C98-A6C6-ECC84D6522E6","adam_id":1479910592,"build_version":"2.10.5","bundleID":"com.ifrontiers.v1game","share_with_app_devs":1,"is_first_party":0,"bug_type":"206","os_version":"iPhone OS 14.6 (18F72)","incident_id":"52B8AB54-5DED-4DD8-AF01-5C6BAD503268","name":"V1 Game"}
Date/Time: 2021-06-07 13:24:44.799 -0700
End time: 2021-06-07 13:25:34.312 -0700
OS Version: iPhone OS 14.6 (Build 18F72)
Architecture: arm64e
Report Version: 32
Incident Identifier: 52B8AB54-5DED-4DD8-AF01-5C6BAD503268
Share With Devs: Yes

Data Source: Microstackshots
Shared Cache: 3CD7DCF2-923C-3BC9-B5E1-E8596EE71C1C slid base address 0x1a737c000, slide 0x2737c000

Command: V1 Game
Path: /private/var/containers/Bundle/Application/A9F4998D-C84C-4589-B645-3482840E02AF/V1 Game.app/V1 Game
Identifier: com.ifrontiers.v1game
Version: 2.10.5 (2.10.5)
Adam ID: 1479910592
Is First Party: No
Beta Identifier: C4FDAADB-43C1-474D-918B-9BA27397EF10
PID: 447

Event: cpu usage
Action taken: Process killed
CPU: 48 seconds cpu time over 50 seconds (97% cpu average), exceeding limit of 80% cpu over 60 seconds
CPU limit: 48s
Limit duration: 60s
CPU used: 48s
CPU duration: 50s
Duration: 49.51s
Duration Sampled: 41.24s
Steps: 15

Hardware model: iPhone12,3
Active cpus: 6

Heaviest stack for the target process:
15 ??? (libsystem_pthread.dylib + 14244) [0x1f333e7a4]
15 ??? (libdispatch.dylib + 95420) [0x1a73da4bc]
15 ??? (libdispatch.dylib + 52224) [0x1a73cfc00]
15 ??? (libdispatch.dylib + 49156) [0x1a73cf004]
15 ??? (libdispatch.dylib + 18460) [0x1a73c781c]
15 ??? (libdispatch.dylib + 10884) [0x1a73c5a84]
15 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 326652) [0x1051f7bfc]
15 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 440148) [0x105213754]
15 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 439936) [0x105213680]
15 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 68660) [0x1051b8c34]
15 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 68888) [0x1051b8d18]
15 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 220684) [0x1051dde0c]
15 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 227592) [0x1051df908]
8 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 271404) [0x1051ea42c]
8 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 278248) [0x1051ebee8]
8 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 348980) [0x1051fd334]
8 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 445764) [0x105214d44]
7 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 451964) [0x10521657c]
7 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 65408) [0x1051b7f80]
7 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 94952) [0x1051bf2e8]
7 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 95160) [0x1051bf3b8]
4 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 37532) [0x1051b129c]
3 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 95384) [0x1051bf498]
3 ??? (<3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> + 203712) [0x1051d9bc0]
2 ??? (Foundation + 133600) [0x1a8a539e0]
2 ??? (Foundation + 16976) [0x1a8a37250]
1 ??? (libobjc.A.dylib + 8708) [0x1bc27b204]

Powerstats for: V1 Game [447]
UUID: 92B8550F-24FA-3C98-A6C6-ECC84D6522E6
Adam ID: 1479910592
Is First Party: No
Beta Identifier: C4FDAADB-43C1-474D-918B-9BA27397EF10
App Version: 2.10.5
Build Version: 2.10.5
Path: /private/var/containers/Bundle/Application/A9F4998D-C84C-4589-B645-3482840E02AF/V1 Game.app/V1 Game
Architecture: arm64
Footprint: 237.64 MB
Start time: 2021-06-07 13:24:50.110 -0700
End time: 2021-06-07 13:25:31.347 -0700
Num samples: 15 (100%)
Primary state: 15 samples Non-Frontmost App, Non-Suppressed, User mode, Effective Thread QoS Background, Requested Thread QoS Default, Override Thread QoS Unspecified
User Activity: 15 samples Idle, 0 samples Active
Power Source: 15 samples on Battery, 0 samples on AC
15 _pthread_wqthread + 275 (libsystem_pthread.dylib + 14244) [0x1f333e7a4]
15 _dispatch_workloop_worker_thread + 763 (libdispatch.dylib + 95420) [0x1a73da4bc]
15 _dispatch_lane_invoke + 403 (libdispatch.dylib + 52224) [0x1a73cfc00]
15 _dispatch_lane_serial_drain + 619 (libdispatch.dylib + 49156) [0x1a73cf004]
15 _dispatch_client_callout + 19 (libdispatch.dylib + 18460) [0x1a73c781c]
15 _dispatch_call_block_and_release + 31 (libdispatch.dylib + 10884) [0x1a73c5a84]
15 __31-[FSRWebSocket _handleMessage:]_block_invoke (FSRWebSocket.m:787 in FirebaseDatabase + 326652) [0x1051f7bfc]
15 -[FWebSocketConnection handleIncomingFrame:] (FWebSocketConnection.m:315 in FirebaseDatabase + 440148) [0x105213754]
15 -[FWebSocketConnection appendFrame:] (FWebSocketConnection.m:303 in FirebaseDatabase + 439936) [0x105213680]
15 -[FConnection onMessage:withMessage:] (FConnection.m:0 in FirebaseDatabase + 68660) [0x1051b8c34]
15 -[FConnection onDataMessage:] (FConnection.m:169 in FirebaseDatabase + 68888) [0x1051b8d18]
15 -[FPersistentConnection onDataMessage:withMessage:] (FPersistentConnection.m:376 in FirebaseDatabase + 220684) [0x1051dde0c]
15 __33-[FPersistentConnection sendPut:]_block_invoke (FPersistentConnection.m:741 in FirebaseDatabase + 227592) [0x1051df908]
8 __39-[FRepo update:withNodes:withCallback:]_block_invoke (FRepo.m:396 in FirebaseDatabase + 271404) [0x1051ea42c]
8 -[FRepo ackWrite:rerunTransactionsAtPath:status:] (FRepo.m:667 in FirebaseDatabase + 278248) [0x1051ebee8]
8 -[FSyncTree ackUserWriteWithWriteId:revert:persist:clock:] (FSyncTree.m:226 in FirebaseDatabase + 348980) [0x1051fd334]
8 -[FWriteTree removeWriteId:] (FWriteTree.m:159 in FirebaseDatabase + 445764) [0x105214d44]
7 -[FWriteTree record:containsPath:] (FWriteTree.m:467 in FirebaseDatabase + 451964) [0x10521657c]
7 -[FCompoundWrite enumerateWrites:] (FCompoundWrite.m:247 in FirebaseDatabase + 65408) [0x1051b7f80]
7 -[FImmutableTree forEach:] (FImmutableTree.m:426 in FirebaseDatabase + 94952) [0x1051bf2e8]
7 -[FImmutableTree forEachPathSoFar:withBlock:] (FImmutableTree.m:431 in FirebaseDatabase + 95160) [0x1051bf3b8]
4 -[FArraySortedDictionary enumerateKeysAndObjectsReverse:usingBlock:] (FArraySortedDictionary.m:233 in FirebaseDatabase + 37532) [0x1051b129c]
3 __45-[FImmutableTree forEachPathSoFar:withBlock:]_block_invoke (FImmutableTree.m:434 in FirebaseDatabase + 95384) [0x1051bf498]
3 -[FPath childFromString:] (FPath.m:195 in FirebaseDatabase + 203712) [0x1051d9bc0]
2 -[NSString componentsSeparatedByString:] + 95 (Foundation + 133600) [0x1a8a539e0]
2 -[NSString rangeOfString:options:range:locale:] + 275 (Foundation + 16976) [0x1a8a37250]
1 objc_msgSend + 68 (libobjc.A.dylib + 8708) [0x1bc27b204]
1 CFStringGetCharacters + 0 (CoreFoundation + 833492) [0x1a777c7d4]
1 objc_msgSend + 39 (libobjc.A.dylib + 8680) [0x1bc27b1e8]
1 free + 147 (libsystem_malloc.dylib + 78496) [0x1b6dff2a0]
1 nanov2_pointer_size + 52 (libsystem_malloc.dylib + 56880) [0x1b6df9e30]
1 objc_retain + 24 (libobjc.A.dylib + 154760) [0x1bc29ec88]
1 objc_retain + 8 (libobjc.A.dylib + 154744) [0x1bc29ec78]
1 objc_msgSend + 68 (libobjc.A.dylib + 8708) [0x1bc27b204]
1 -[FWriteTree record:containsPath:] (FWriteTree.m:464 in FirebaseDatabase + 451804) [0x1052164dc]
1 objc_msgSend + 39 (libobjc.A.dylib + 8680) [0x1bc27b1e8]
7 __35-[FRepo set:withNode:withCallback:]_block_invoke (FRepo.m:351 in FirebaseDatabase + 270128) [0x1051e9f30]
7 -[FRepo ackWrite:rerunTransactionsAtPath:status:] (FRepo.m:667 in FirebaseDatabase + 278248) [0x1051ebee8]
7 -[FSyncTree ackUserWriteWithWriteId:revert:persist:clock:] (FSyncTree.m:226 in FirebaseDatabase + 348980) [0x1051fd334]
7 -[FWriteTree removeWriteId:] (FWriteTree.m:159 in FirebaseDatabase + 445764) [0x105214d44]
7 -[FWriteTree record:containsPath:] (FWriteTree.m:467 in FirebaseDatabase + 451964) [0x10521657c]
7 -[FCompoundWrite enumerateWrites:] (FCompoundWrite.m:247 in FirebaseDatabase + 65408) [0x1051b7f80]
7 -[FImmutableTree forEach:] (FImmutableTree.m:426 in FirebaseDatabase + 94952) [0x1051bf2e8]
7 -[FImmutableTree forEachPathSoFar:withBlock:] (FImmutableTree.m:431 in FirebaseDatabase + 95160) [0x1051bf3b8]
7 -[FArraySortedDictionary enumerateKeysAndObjectsReverse:usingBlock:] (FArraySortedDictionary.m:233 in FirebaseDatabase + 37532) [0x1051b129c]
5 __45-[FImmutableTree forEachPathSoFar:withBlock:]_block_invoke (FImmutableTree.m:434 in FirebaseDatabase + 95384) [0x1051bf498]
2 -[FPath childFromString:] (FPath.m:195 in FirebaseDatabase + 203712) [0x1051d9bc0]
2 -[NSString componentsSeparatedByString:] + 95 (Foundation + 133600) [0x1a8a539e0]
1 -[NSObject superclass] + 95 (libobjc.A.dylib + 8640) [0x1bc27b1c0]
1 -[NSString rangeOfString:options:range:locale:] + 275 (Foundation + 16976) [0x1a8a37250]
1 CFStringFindWithOptionsAndLocale + 3660 (CoreFoundation + 853780) [0x1a7781714]
2 -[FPath childFromString:] (FPath.m:203 in FirebaseDatabase + 203872) [0x1051d9c60]
1 _objc_rootAllocWithZone + 92 (libobjc.A.dylib + 117952) [0x1bc295cc0]
1 _objc_rootAllocWithZone + 39 (libobjc.A.dylib + 117900) [0x1bc295c8c]
1 default_zone_calloc + 12 (libsystem_malloc.dylib + 88204) [0x1b6e0188c]
1 objc_msgSend + 27 (libobjc.A.dylib + 8668) [0x1bc27b1dc]
2 __45-[FImmutableTree forEachPathSoFar:withBlock:]_block_invoke (FImmutableTree.m:434 in FirebaseDatabase + 95420) [0x1051bf4bc]
2 -[FImmutableTree forEachPathSoFar:withBlock:] (FImmutableTree.m:438 in FirebaseDatabase + 95252) [0x1051bf414]
1 __34-[FWriteTree record:containsPath:]_block_invoke (FWriteTree.m:469 in FirebaseDatabase + 452236) [0x10521668c]
1 _objc_rootDealloc + 79 (libobjc.A.dylib + 148932) [0x1bc29d5c4]
1 objc_destructInstance + 79 (libobjc.A.dylib + 119112) [0x1bc296148]
1 object_cxxDestructFromClass + 111 (libobjc.A.dylib + 23768) [0x1bc27ecd8]
1 -[__NSArrayM dealloc] + 303 (CoreFoundation + 10088) [0x1a76b3768]
1 free + 147 (libsystem_malloc.dylib + 78496) [0x1b6dff2a0]
1 nanov2_size + 36 (libsystem_malloc.dylib + 56772) [0x1b6df9dc4]
1 __34-[FWriteTree record:containsPath:]_block_invoke (FWriteTree.m:469 in FirebaseDatabase + 452176) [0x105216650]
1 -[FPath child:] (FPath.m:178 in FirebaseDatabase + 202996) [0x1051d98f4]
1 -[__NSArrayM insertObject:atIndex:] + 267 (CoreFoundation + 10412) [0x1a76b38ac]
1 _malloc_zone_malloc + 151 (libsystem_malloc.dylib + 76192) [0x1b6dfe9a0]
1 nanov2_malloc + 63 (libsystem_malloc.dylib + 57152) [0x1b6df9f40]
1 nanov2_allocate + 127 (libsystem_malloc.dylib + 57380) [0x1b6dfa024]
1 nanov2_allocate_from_block + 240 (libsystem_malloc.dylib + 61004) [0x1b6dfae4c]

Binary Images:
0x104094000 - ??? com.ifrontiers.v1game 2.10.5 (2.10.5) <92B8550F-24FA-3C98-A6C6-ECC84D6522E6> /private/var/containers/Bundle/Application/A9F4998D-C84C-4589-B645-3482840E02AF/V1 Game.app/V1 Game
0x1051a8000 - ??? ??? <3C0EEB14-07E2-32BC-9947-1F8C513BEDFE> FirebaseDatabase
0x1a73c3000 - 0x1a7407fff libdispatch.dylib /usr/lib/system/libdispatch.dylib
0x1a76b1000 - 0x1a7a70fff CoreFoundation <4FBDF167-161A-324C-A233-D516922C67E5> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x1a8a33000 - 0x1a8ce8fff Foundation <0D9893A4-5804-3F0D-BB3F-73989EA36AD3> /System/Library/Frameworks/Foundation.framework/Foundation
0x1b6dec000 - 0x1b6e0ffff libsystem_malloc.dylib <716786F4-DA96-3293-BB00-7ED833124DEA> /usr/lib/system/libsystem_malloc.dylib
0x1bc279000 - 0x1bc2b0fff libobjc.A.dylib <266E9238-111C-3F2D-A0D2-604474E3CDC4> /usr/lib/libobjc.A.dylib
0x1f333b000 - 0x1f3346fff libsystem_pthread.dylib <3690509E-E1E0-3F8C-8935-688B599C0303> /usr/lib/system/libsystem_pthread.dylib

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions