Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1deeac8

Browse files
[CP-beta][Android] post image task to main handler. (#52166)
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? Test failures in Impeller migration PR: flutter/packages#6461 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/wiki/Hotfix-Documentation-Best-Practices) for examples Ensure that Android platform view updates are posted on correct thread when platform view is created on background handler. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) Migration to Impeller plugin APIs is blocked. ### Workaround: Is there a workaround for this issue? Disable impeller ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? However the tests are in flutter/packages and not flutter/engine. ### Validation Steps: What are the steps to validate that this fix works? Run the unit tests on the linked PR in flutter/packages
1 parent 41d578d commit 1deeac8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import android.media.ImageReader;
1818
import android.os.Build;
1919
import android.os.Handler;
20+
import android.os.Looper;
2021
import android.view.Surface;
2122
import androidx.annotation.Keep;
2223
import androidx.annotation.NonNull;
@@ -479,7 +480,8 @@ private class PerImageReader {
479480

480481
public PerImageReader(ImageReader reader) {
481482
this.reader = reader;
482-
reader.setOnImageAvailableListener(onImageAvailableListener, new Handler());
483+
reader.setOnImageAvailableListener(
484+
onImageAvailableListener, new Handler(Looper.getMainLooper()));
483485
}
484486

485487
PerImage queueImage(Image image) {

0 commit comments

Comments
 (0)