Skip to content

Crash in fetchAuthValue when App is Resumed from Background #187

@hschk

Description

@hschk

Description

Our Flutter app sometimes crashes when resuming after being in the background for a while. The issue seems to originate from the fetchAuthValue method in the Pusher library. The crash is related to a dynamic cast failure, as seen in the Crashlytics logs (provided below).

I suspect the issue might be caused by an invalid state or incorrect handling of the authorizer object during app lifecycle changes.

Environment Details

  • Pusher Library Version: 2.4.0
  • Flutter Version: 3.27.1
  • Platform: iOS

Crash Logs

Here is the relevant portion of the Crashlytics log:

Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0xc1d4 __pthread_kill + 8
1  libsystem_pthread.dylib        0x7ef8 pthread_kill + 268
2  libsystem_c.dylib              0x77ad8 abort + 128
3  libswiftCore.dylib             0x3cc1a4 swift::fatalError(unsigned int, char const*, ...) + 134
4  libswiftCore.dylib             0x3bfb44 swift::swift_dynamicCastFailure(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, char const*) + 78
5  pusher_channels_flutter        0x9d88 partial apply for closure #1 in SwiftPusherChannelsFlutterPlugin.fetchAuthValue(socketID:channelName:completionHandler:) + 107 (SwiftPusherChannelsFlutterPlugin.swift:107)

If any additional information is needed, please let us know.
Would appreciate any guidance or fixes from the team. Thanks!

Full Crashlytics Log:

 Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0xc1d4 __pthread_kill + 8
1  libsystem_pthread.dylib        0x7ef8 pthread_kill + 268
2  libsystem_c.dylib              0x77ad8 abort + 128
3  libswiftCore.dylib             0x3cc1a4 swift::fatalError(unsigned int, char const*, ...) + 134
4  libswiftCore.dylib             0x3cc1c4 swift::warningv(unsigned int, char const*, char*) + 30
5  libswiftCore.dylib             0x3bfb44 swift::swift_dynamicCastFailure(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, char const*) + 78
6  libswiftCore.dylib             0x3bfbc0 swift::_conformsToProtocol(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptorRef<swift::InProcess>, swift::TargetWitnessTable<swift::InProcess> const**) + 122
7  libswiftCore.dylib             0x3c4f68 swift_dynamicCastImpl(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 342
8  pusher_channels_flutter        0x9d88 partial apply for closure #1 in SwiftPusherChannelsFlutterPlugin.fetchAuthValue(socketID:channelName:completionHandler:) + 107 (SwiftPusherChannelsFlutterPlugin.swift:107)
9  pusher_channels_flutter        0x5bec thunk for @escaping @callee_guaranteed (@in_guaranteed Any?) -> () + 84 (<compiler-generated>:84)
10 Flutter                        0x5e2468 __54-[FlutterMethodChannel invokeMethod:arguments:result:]_block_invoke + 291 (FlutterChannels.mm:291)
11 Flutter                        0x5a178 std::_fl::__function::__func<fml::internal::CopyableLambda<flutter::PlatformMessageResponseDarwin::Complete(std::_fl::unique_ptr<fml::Mapping, std::_fl::default_delete<fml::Mapping>>)::$_0>, std::_fl::allocator<fml::internal::CopyableLambda<flutter::PlatformMessageResponseDarwin::Complete(std::_fl::unique_ptr<fml::Mapping, std::_fl::default_delete<fml::Mapping>>)::$_0>>, void ()>::operator()() + 24 (platform_message_response_darwin.mm:24)
12 Flutter                        0x85c9c fml::MessageLoopImpl::FlushTasks(fml::FlushType) + 128 (message_loop_impl.cc:128)
13 Flutter                        0x89314 fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*) + 86 (message_loop_darwin.mm:86)
14 CoreFoundation                 0xb4894 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
15 CoreFoundation                 0xb4538 __CFRunLoopDoTimer + 1012
16 CoreFoundation                 0xb408c __CFRunLoopDoTimers + 288
17 CoreFoundation                 0x533b4 __CFRunLoopRun + 1856
18 CoreFoundation                 0x52830 CFRunLoopRunSpecific + 588
19 GraphicsServices               0x11c4 GSEventRunModal + 164
20 UIKitCore                      0x3d2eb0 -[UIApplication _run] + 816
21 UIKitCore                      0x4815b4 UIApplicationMain + 340
22 UIKitCore                      0x7bbfa8 block_destroy_helper.23 + 10212
23 Runner                         0x88cc main + 4343269580 (AppDelegate.swift:4343269580)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions