mobile_scanner icon indicating copy to clipboard operation
mobile_scanner copied to clipboard

Camera won't work when impeller enabled on Android

Open JgomesAT opened this issue 1 year ago • 14 comments

This message has been updated to outline the most up-to-date information on this bug. The original comment is kept at the bottom

When this bug was filed, Impeller on Android was still in preview, with some open work relating to platform views still pending. This work has since concluded and resulted in both 1P plugins (camera, video_player) being updated to support Impeller. There is also a migration doc for plugin authors, available at https://docs.flutter.dev/release/breaking-changes/android-surface-plugins

This migration doc outlines what mobile_scanner must do to support Impeller. Most notably we should do the following:

  1. Set the minimum supported Flutter version to 3.24, per the note in the migration doc
  2. Migrate from SurfaceTexture to SurfaceProducer (we do have usages of SurfaceTexture, which explains why it isn't working)
  3. Correct the preview orientation for the camera, since the new SurfaceProducer does not provide the rotation. This is outlined in an update to the above migration doc at https://github.com/flutter/website/pull/11008 Depending on when the fix for mobile_scanner is written, we can consult the updated migration doc or the open PR

The message below is the un-edited original post for this issue

With the recent improvement of Impeller on Flutter 3.16 I tried to compile my app with <meta-data android:name="flutterEmbedding" android:value="2" /> <meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="true" />

with this, the camera is black and does not work, in iOS with impeller works fine

JgomesAT avatar Nov 17 '23 10:11 JgomesAT

Same problem for me.

frankmer avatar Nov 21 '23 09:11 frankmer

Impeller for Android is still in preview. On Android API 29+ this uses Vulkan, which still has some issues with platform views.

navaronbracke avatar Nov 21 '23 18:11 navaronbracke

is there any change with the new Flutter 3.19 and IMpeller, this library is not working with this option

JgomesAT avatar Feb 19 '24 15:02 JgomesAT

As I started above, Impeller on Android is still in preview. Work on external textures has progressed however. A patch for this is about to land on flutter/engine. If you absolutely need Impeller on Android right now, your best bet is to switch to the master channel. But that is at your own risk, since the master channel is not for production apps.

navaronbracke avatar Feb 20 '24 09:02 navaronbracke

As I started above, Impeller on Android is still in preview. Work on external textures has progressed however. A patch for this is about to land on flutter/engine. If you absolutely need Impeller on Android right now, your best bet is to switch to the master channel. But that is at your own risk, since the master channel is not for production apps.

I have the same problem. I have updated my local flutter version to the latest main channel but the problem persists:

Flutter is already up to date on channel main
Flutter 3.22.0-5.0.pre.34 • channel main • https://github.com/flutter/flutter.git
Framework • revision 45deb49716 (2 hours ago) • 2024-04-05 03:42:30 -0700
Engine • revision 292c48b9af
Tools • Dart 3.5.0 (build 3.5.0-18.0.dev) • DevTools 2.34.1

You mention that this has been fixed on the current master channel, can you confirm on what version you have tested this?

My mobile_scanner version is on 5.0.0-beta.2.

mfiumara avatar Apr 05 '24 12:04 mfiumara