fix(android): handle null versionName in isNewBinary()#8397
Open
dawiddominiak wants to merge 1 commit intoionic-team:mainfrom
Open
fix(android): handle null versionName in isNewBinary()#8397dawiddominiak wants to merge 1 commit intoionic-team:mainfrom
dawiddominiak wants to merge 1 commit intoionic-team:mainfrom
Conversation
PackageInfo.versionName is @nullable on Android. When it returns null (e.g. on sideloaded APKs or certain emulator builds where versionName is not set in the manifest), the .equals() call on line 442 throws a NullPointerException, crashing the app on startup before the WebView even loads. Null-coalesce to "" which matches the variable's initializer on line 425, so the comparison still works correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Bridge.isNewBinary()crashes with aNullPointerExceptionon app startup. The culprit is line 437:PackageInfo.versionNameis@Nullableon Android. When it's null, line 442 blows up:The variable starts as
""on line 425, but gets overwritten with null frompInfo.versionName. Then.equals()is called on null. Game over.This happens on sideloaded APKs and some emulator builds where
versionNameisn't set in the manifest. We hit it in production on a Pixel 6 Pro emulator running Android 12.Fix
One-line change: null-coalesce
pInfo.versionNameback to""(matching the initializer on line 425). The comparison logic stays exactly the same.Stack trace from Sentry