mobile_scanner (CameraX) on MediaTek MT6761 / Android 9: camera starts but no frames after app is force-stopped, until reboot


I'm building an inventory app in Flutter that scans barcodes with the rear camera using mobile_scanner (CameraX backend) on a rugged PDA (Symphony M1, MediaTek MT6761, Android 9). It works at first, but after I force-stop the app from the recents screen, the camera opens without errors and never delivers frames. Only a device reboot recovers it.

Environment

DeviceSymphony M1 (ro.product.model=M1, manufacturer alps)SoC / BSPMediaTek MT6761 (k61v1_32_bsp_hdp, alps-mp-p0.mp1-V5.69)Android9 (SDK 28), security patch 2019-03-05, user build (no root)BuildSymphony/M1/M1:9/PPR1.180610.011/11280158:user/release-keysABIarmeabi-v7a onlyCameras3: ID 0 = back (8 MP AF), ID 1 = front, ID 2 = back (SE4710 scan engine)Flutter pluginmobile_scanner: ^7.4.2

Steps to reproduce

  1. Launch the app, open the scanner screen. Barcodes are detected normally.

  2. Close the scanner and reopen it. Still works.

  3. Force-stop the app from the recents screen.

  4. Launch the app again and open the scanner.

  5. start() completes without exception, but onDetect is never called. No frames arrive.

  6. Rebooting the device fixes it until the next force-stop.

Controller setup

dart

final controller = MobileScannerController(
  formats: supportedFormats,
  detectionSpeed: DetectionSpeed.normal,
  detectionTimeoutMs: 500,
  facing: CameraFacing.back,
  torchEnabled: false,
  autoStart: false,
);

// later
await controller.start(); // succeeds every time

dart

MobileScanner(controller: controller, onDetect: (capture) { /* never called */ });

What I observed

  • start() returns successfully on every attempt. No MobileScannerException, no permission error.

  • A watchdog I added ("no onDetect within 3 s") fires every time. Disposing and recreating the controller up to 4 times (with 2 s delays) does not help, and it logs this in CameraService:

  CameraService::connect call (PID -1 "com.example.frontend", camera ID 0) ...
  CameraService::connect evicting conflicting client for camera ID 0
  • While the scanner is open, dumpsys media.camera shows device 0 held by my app with no conflicting clients:
  (Camera ID: 0, ... Client Package Name: com.example.frontend, Conflicting Client Devices: {})
  Device 1 is closed, no client instance
  Device 2 is closed, no client instance
  • Right after the force-stop, dumpsys media.camera shows all three devices as closed, no client instance, so no client seems to be holding the camera at the CameraService level.

  • The stock camera app (com.mediatek.camera) connects to device 0 without trouble.

I cannot get a root shell (adbd cannot run as root in production builds), and SELinux blocks shell and app access to the vendor HALs (e.g. avc: denied { find } ... hal_zebrascanner_hwservice), so I can't inspect the camera HAL directly.

What I tried

  • Waiting 500 ms to 2 s between stop()/dispose() and creating a new controller.

  • Recreating the controller up to 4 times when no frame arrives (made it worse: the evicting conflicting client message above).

  • Stopping the controller on AppLifecycleState.paused/inactive/hidden and restarting on resumed.

  • Keeping a single persistent scanner widget mounted (shown/hidden with Offstage), because CameraX ImageAnalysis didn't re-attach after unmounting on this SoC.

Question

  1. Is this a known problem with the MediaTek camera HAL on MT6761 / Android 9 when the client process is killed, so that the next session opens but produces no frames? Is there a documented workaround from the app side?

  2. Can a CameraX app detect this state and recover without a reboot (e.g. resetting the camera provider, using a different ImplementationMode, or falling back to Camera2 directly)?

  3. If it is a firmware bug, is there any way to confirm that from a non-root app (for example specific logcat tags from cameraserver / camera.provider / mtkcam)?

Would a minimal native CameraX app (no Flutter) be a meaningful test to separate a plugin problem from a HAL problem? I haven't done that yet.

0
Oct 5 at 11:47 AM
User AvatarReza Chairul
#android#flutter#barcode-scanner#android-camerax

No answer found for this question yet.