-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix resize crash in Android virtual display #37329
Fix resize crash in Android virtual display #37329
Conversation
In the Virtual Display codepath for Android platform views, resize completes asynchronously. Currently it is attempting to access the Context in the completion handler, but there is no guarantee that it is still present at that point, leading to possible null pointer crashes. This adds a check for the current state of the Context, and uses a fallback if it's not available. Fixes flutter/flutter#114095
GaryQian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| physicalHeight, | ||
| () -> { | ||
| unlockInputConnection(vdController); | ||
| // Converting back to logic pixels requires a context, which may no longer be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like the only way this fails is if the user changes the scale/UI density in the settings app while the Flutter app is running, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a reasonable tradeoff vs crashing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, and they'd have to do it during this race, which seems pretty unlikely.
And I'm still not sure what the repro for this is; it may well be that it only happens during teardown and the return value will be ignored anyway.
…115478) * 7a5bc9124 Roll Skia from 4b3d36f36bf3 to 74a57221dfb3 (7 revisions) (flutter/engine#37675) * f4ca3e7a0 [fuchsia] Fix shader warmup. (flutter/engine#37662) * 97974ebb5 Fix resize crash in Android virtual display (flutter/engine#37329)
…lutter#115478) * 7a5bc9124 Roll Skia from 4b3d36f36bf3 to 74a57221dfb3 (7 revisions) (flutter/engine#37675) * f4ca3e7a0 [fuchsia] Fix shader warmup. (flutter/engine#37662) * 97974ebb5 Fix resize crash in Android virtual display (flutter/engine#37329)
…lutter#115478) * 7a5bc9124 Roll Skia from 4b3d36f36bf3 to 74a57221dfb3 (7 revisions) (flutter/engine#37675) * f4ca3e7a0 [fuchsia] Fix shader warmup. (flutter/engine#37662) * 97974ebb5 Fix resize crash in Android virtual display (flutter/engine#37329)
In the Virtual Display codepath for Android platform views, resize completes asynchronously. Currently it is attempting to access the Context in the completion handler, but there is no guarantee that it is still present at that point, leading to possible null pointer crashes.
This adds a check for the current state of the Context, and uses a fallback if it's not available.
Fixes flutter/flutter#114095
Pre-launch Checklist
///).