PostHog / posthog-ios

PostHog iOS SDK
https://posthog.com/docs/libraries/ios
MIT License
32 stars 41 forks source link

Crash on launch #2

Closed joshkopecek closed 4 years ago

joshkopecek commented 4 years ago

I am getting an Exception when loading the lib. It's caused when invoking PHGPostHog.setup(with: configuration).

This happens no matter whether I enable captureApplicationLifecycleEvents or not (since it's related to applicationDidFinishLaunching.

2020-05-13 17:02:33.310694+0100 ECHOES[5617:2930869] -[PHGPostHogIntegration applicationDidFinishLaunching:]: unrecognized selector sent to instance 0x600002614600
2020-05-13 17:02:33.312232+0100 ECHOES[5617:2930869] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PHGPostHogIntegration applicationDidFinishLaunching:]: unrecognized selector sent to instance 0x600002614600'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23e39f0e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff50ad79b2 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23e5ac34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x00007fff23e3e6b6 ___forwarding___ + 838
    4   CoreFoundation                      0x00007fff23e40bf8 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x00007fff23e40e8c __invoking___ + 140
    6   CoreFoundation                      0x00007fff23e3e071 -[NSInvocation invoke] + 321
    7   CoreFoundation                      0x00007fff23e3e344 -[NSInvocation invokeWithTarget:] + 68
    8   PostHog                             0x000000010ac26512 -[PHGPayloadManager invokeIntegration:key:selector:arguments:options:] + 290
    9   PostHog                             0x000000010ac263b5 -[PHGPayloadManager forwardSelector:arguments:options:] + 165
    10  PostHog                             0x000000010ac26fa7 __56-[PHGPayloadManager callWithSelector:arguments:options:]_block_invoke + 135
    11  PostHog                             0x000000010ac330a1 __phg_dispatch_specific_block_invoke + 49
    12  libdispatch.dylib                   0x000000010d52bf11 _dispatch_call_block_and_release + 12
    13  libdispatch.dylib                   0x000000010d52ce8e _dispatch_client_callout + 8
    14  libdispatch.dylib                   0x000000010d5336fd _dispatch_lane_serial_drain + 788
    15  libdispatch.dylib                   0x000000010d53428f _dispatch_lane_invoke + 422
    16  libdispatch.dylib                   0x000000010d53fb65 _dispatch_workloop_worker_thread + 719
    17  libsystem_pthread.dylib             0x00007fff51b37a3d _pthread_wqthread + 290
    18  libsystem_pthread.dylib             0x00007fff51b36b77 start_wqthread + 15
)
joshkopecek commented 4 years ago

I can confirm disabling line 95 in PHGPayloadManager.m temporarily fixes the crash. This is only a workaround though, as it disables the lifecycle analytics.

mariusandra commented 4 years ago

Hi @joshkopecek , thanks for raising this! I have managed to replicate the problem and I'm working on finding a fix. I'll keep you posted, although it might take until Monday.

joshkopecek commented 4 years ago

Thank you @mariusandra ! I'll keep an eye on this thread.

mariusandra commented 4 years ago

Hi again @joshkopecek , all these issues should be fixed with version 1.0.2 of the library. Please try it out and let me know if it works!

joshkopecek commented 4 years ago

@mariusandra just checked and that fixed it. Thanks for the prompt response!

mariusandra commented 4 years ago

Awesome! Please let me know if there's anything else I can help with :)