-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in fetchAuthValue when App is Resumed from Background #187
Comments
I’m not sure if this is related, but when I reopen the app after it has been in the background, I see a series of connection state change logs like this:
Is this expected behavior? As I mentioned, this might not be an issue or even related to the crashes, but I thought it was worth noting while troubleshooting. |
which version of the pusher channel flutter library r u using? |
When I reported this issue, I was using version 2.4.0. However, the same behavior occurs with version 2.5.0. |
Thank you for your response and for offering to help! I also suspected that the issue might lie within my onAuthorizer code. However, after reviewing our server logs, it appears that our Pusher auth endpoint was returning the expected response with a 200 status code and the correct authentication object at the time of the last crash. To provide more context, here is my PusherService class implementation:
|
Here is the line 107 code that causes your app crash:
That said, I can see that you already cast your Map to <String, String>, so theoretically, it shouldn't crash. However, there might still be edge cases where invalid or improperly formatted data could cause issues. I recommend adding additional validation and controls to your _onAuthorizer implementation to ensure robustness. You can check out the _onAuthorizer implementation in my pusher_service.dart file in this repository for reference: |
I recently added the try-catch block to the onAuthorizer implementation on the Dart side. It’s possible that before this change, an exception might have caused an unexpected value to be returned to the invokeMethod callback in Swift, which could potentially explain the crash. That said, during the last app crashes, everything appeared normal in our server logs — there were no errors or anomalies reported. However, it’s still possible that an exception occurred somewhere else in the flow, which I might have missed. I'm continuing to investigate this, especially with your provided validation and controls for onAuthorizer, and will provide updates if we find anything conclusive. |
I am also seeing this issue on iOS 18 and iPhone 14 Plus, under my crashlytics I see, $s23pusher_channels_flutter32SwiftPusherChannelsFlutterPluginC14fetchAuth and, Could not cast value of type 'NSNull' (0x1f5862190) to 'webview_flutter_wkwebview.AuthenticationChallengeResponse' (0x1023275d8). |
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
Crash Logs
Here is the relevant portion of the Crashlytics log:
If any additional information is needed, please let us know.
Would appreciate any guidance or fixes from the team. Thanks!
Full Crashlytics Log:
The text was updated successfully, but these errors were encountered: