-
Notifications
You must be signed in to change notification settings - Fork 9
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
NullPointerException in PortalFragment; potential problems with Fragment-recreations #112
Comments
Thanks for reporting, what version of Portals are you seeing the errors from? |
Previously, I was seeing those errors with 0.2.1. |
Someone else reported NPE crashes that were similar that we made a fix for in #95 so I was curious if that might resolve it for you. That fix is in 0.3.1. |
Yeah this seems like a related fix. I will let you know if something happens with 0.3.1, if nothing happens then I will close this issue within a week. |
Unfortunately I received the same stacktrace again with my new app-version, which means that the error is not fixed with 0.3.1. |
Small sidenote: I embedded a PortalView into a larger RelativeLayout like this: <io.ionic.portals.PortalView
app:portalId="MyPortalID"
android:layout_below="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent" /> So I instantiate Portals via XML-layouts, but not directly via Kotlin-code. |
Thanks for the feedback, I will take a look and see if I can pinpoint the cause. |
I think I found the cause and pushed a fix. We will release this asap |
Look out for Portals 0.4.1 - the fix is published! Thanks for reporting. Please let us know if you still encounter an issue |
Thank you for publishing a fix! |
Dear ionic-team,
After using Portals successfully in production for multiple weeks, I noticed hundreds of NullPointerExceptions in my sentry.io crash-reports. Specifically, a NullPointerException happened in the following line:
https://github.com/ionic-team/ionic-portals/blob/main/android/IonicPortals/src/main/kotlin/io/ionic/portals/PortalFragment.kt#L99
Here is the stacktrace that was reported by sentry.io:
I suspect that this happens when a PortalFragment gets instantiated without an instance of the Portal-class.
For example, such erroneous instantiations might happen when the following empty default-constructor of a PortalFragment gets invoked:
https://github.com/ionic-team/ionic-portals/blob/main/android/IonicPortals/src/main/kotlin/io/ionic/portals/PortalFragment.kt#L27
This makes me question whether there is a potential problem with Fragment-recreations.
The Android-OS might destroy and recreate Fragments at any time, and this might trigger the NullPointerException.
Perhaps I could "fix" the bug by adding more null-checks to the problematic code, but my goal would be to find a root-cause instead of only adding null-checks.
The text was updated successfully, but these errors were encountered: