Skip to content

Crash in Amplitude Session Replay during display link (weak hash table mutation) #38

@VladIacobIonut

Description

@VladIacobIonut

Expected Behavior

The app should run smoothly with Amplitude Session Replay enabled, without crashing randomly.

Current Behavior

The app crashes on the main thread during a CADisplayLink callback. The crash originates in the Amplitude Session Replay SDK while manipulating an internal NSHashTable of tracked objects.

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0xcb24 objc_loadWeakRetained + 164
1  libobjc.A.dylib                0xdd34 objc_loadWeak + 24
2  Foundation                     0x674ec -[NSConcreteHashTable hashGrow] + 132
3  Foundation                     0x29974 -[NSConcreteHashTable addObject:] + 144
4  AmplitudeSessionReplay         0x45a80 block_destroy_helper.7 + 6724
5  AmplitudeSessionReplay         0x53e84 block_destroy_helper + 1444
6  AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
7  AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
8  AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
9  AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
10 AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
11 AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
12 AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
13 AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
14 AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
15 AmplitudeSessionReplay         0x548b8 block_destroy_helper + 4056
16 AmplitudeSessionReplay         0x517f8 __swift_allocate_boxed_opaque_existential_1 + 10536
17 AmplitudeSessionReplay         0x512e0 __swift_allocate_boxed_opaque_existential_1 + 9232
18 AmplitudeSessionReplay         0x51a78 __swift_allocate_boxed_opaque_existential_1 + 11176
19 QuartzCore                     0x101d0 CA::Display::DisplayLinkItem::dispatch_(CA::SignPost::Interval<(CA::SignPost::CAEventCode)835322056>&) + 48
20 QuartzCore                     0xfdc8 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 876
21 QuartzCore                     0x10364 CA::Display::DisplayLink::dispatch_deferred_display_links(unsigned int) + 360
22 UIKitCore                      0x9404 _UIUpdateSequenceRun + 84
23 UIKitCore                      0x8ab4 schedulerStepScheduledMainSection + 208
24 UIKitCore                      0x41e4 runloopSourceCallback + 92
25 CoreFoundation                 0xf92c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
26 CoreFoundation                 0xf744 __CFRunLoopDoSource0 + 172
27 CoreFoundation                 0xf5a0 __CFRunLoopDoSources0 + 232
28 CoreFoundation                 0xff20 __CFRunLoopRun + 840
29 CoreFoundation                 0x11adc CFRunLoopRunSpecific + 572
30 GraphicsServices               0x1454 GSEventRunModal + 168
31 UIKitCore                      0x135274 -[UIApplication _run] + 816
32 UIKitCore                      0x100a28 UIApplicationMain + 336
33 UIKitCore                      0x1e2168 __51-[UIStatusBar_Base _setHidden:animationParameters:]_block_invoke_4 + 180

Steps to Reproduce

  1. Use the app with session replays enabled however the crash is not reproducible 100% of the time, but it crashes often enough to be a stability issue for the app.

Environment

  • SDK Version: 0.5.2
  • OS Info: iOS 18.4.1+

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions