Repository navigation
Commit 8f37c46
[Android] Do not schedule engine frames on a detached FlutterJNI (#191204)
`ImageReaderSurfaceProducer.onImage` is invoked from an `ImageReader`
callback posted to the platform thread. When the Activity is destroyed
while a texture producer still has a frame in flight, that callback can
run after `FlutterJNI` has detached, and `scheduleEngineFrame` then
raises `RuntimeException: Cannot execute operation because FlutterJNI is
not attached to native.` on the main looper, crashing the app.
Guard `FlutterRenderer.scheduleEngineFrame` with
`flutterJNI.isAttached()` so all five call sites are covered, mirroring
the check that `SurfaceTextureRegistryEntry`'s frame listener and
`TextureFinalizerRunnable` already perform. Once the engine is detached
there is no engine left to draw the frame, so dropping the request is
the correct behaviour.
Fixes #188300
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Co-authored-by: Gray Mackall <[email protected]>1 parent 58daa63 commit 8f37c46
2 files changed
Lines changed: 53 additions & 0 deletions
File tree
- engine/src/flutter/shell/platform/android
- io/flutter/embedding/engine/renderer
- test/io/flutter/embedding/engine/renderer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1360 | 1360 | | |
1361 | 1361 | | |
1362 | 1362 | | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
1363 | 1370 | | |
1364 | 1371 | | |
1365 | 1372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
991 | 1037 | | |
992 | 1038 | | |
993 | 1039 | | |
| |||
0 commit comments