Repository navigation
Commit 3639929
[Android] Guard PlatformViewsController2.onEndFrame against a detached FlutterView (flutter#190612)
`PlatformViewsController2.onEndFrame()` dereferenced `flutterView` and
the result of `flutterView.getRootSurfaceControl()` without checking
either for null.
`AndroidExternalViewEmbedder2::SubmitFlutterView()` posts `onEndFrame2()`
from the raster thread to the platform thread on every frame, including
frames with no platform layers. By the time the task runs, the
`FlutterView` may have been detached from the controller, in which case
`detachFromView()` has set `flutterView` to null, or detached from its
window, in which case `View.getRootSurfaceControl()` returns null.
The resulting `NullPointerException` is not merely logged. The JNI call
ends with `FML_CHECK(fml::jni::CheckException(env))`, which converts the
pending Java exception into an `abort()`.
This change guards both nullable values and closes the merged
`SurfaceControl.Transaction` before returning early so that it is not
leaked. It also moves `flutterView.invalidate()` below the guard.
Fixes flutter#190609
(cherry picked from commit 8bcda46)
Cherry-pick note: the import hunk was placed by hand because this branch
does not carry flutter#184732 (rect clipping for surface views); nothing else
changed.1 parent c40b49d commit 3639929
2 files changed
Lines changed: 53 additions & 1 deletion
File tree
- engine/src/flutter/shell/platform/android
- io/flutter/plugin/platform
- test/io/flutter/plugin/platform
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
542 | 543 | | |
543 | 544 | | |
544 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
545 | 559 | | |
546 | | - | |
| 560 | + | |
547 | 561 | | |
548 | 562 | | |
549 | 563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
556 | 594 | | |
557 | 595 | | |
558 | 596 | | |
| |||
0 commit comments