Address NullPointerException crash in AztecHeadingSpan
#1071
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.
A potential fix for the crash described at wordpress-mobile/WordPress-Android#18657.
Related PRs
Gutenberg: [RNMobile] AddressNullPointerExceptioncrash inAztecHeadingSpanWordPress/gutenberg#56757Gutenberg Mobile: [RNMobile] AddressNullPointerExceptioncrash inAztecHeadingSpangutenberg-mobile#6435Android: AddressNullPointerExceptioncrash inAztecHeadingSpanWordPress-Android#19724Description
Sentry has been reporting the following crash for both the WordPress and Jetpack Android apps:
The stack trace for each individual event specifically references one of the following lines (the specific line varies for each event), all of which are within the
chooseHeightfunction and include a reference topreviousFontMetrics:As described at wordpress-mobile/WordPress-Android#18657 (comment), it has proven difficult to reproduce this crash. It's suspected that there are specific instances with lower performing devices or devices on poor connections that can lead to
previousFontMetricsbeing set as null elsewhere in the code whilechooseHeightis running.Given the difficulty reproducing, it hasn't been possible to get to the heart of this issue. Instead, with this PR, the previous non-null assertions previously used with
previousFontMetricshave been replaced with safe calls. With this approach, the functionality should remain the same, while guarding againstNullPointerExceptioncrashes.Test
Verify Aztec demo continues to function as expected
Verify Gutenberg continues to function as expected
NullPointerExceptioncrash inAztecHeadingSpanWordPress-Android#19724, install the app and navigate to the post editor.