CamerAwesome icon indicating copy to clipboard operation
CamerAwesome copied to clipboard

[iOS] Camera usage indicator does not go away.

Open BLKKKBVSIK opened this issue 3 years ago • 8 comments

Steps to Reproduce

Create an app using camera_awesome, use the camera, then navigate to any other screen which is not using the camera anymore.

Expected results

On iOS there is a little green dot next to the battery indicator (See screenshot) , showing that the device is using the camera at this moment. It should disappear after navigating to any other screen which is not using the camera.

Screenshot 2021-03-02 at 17 17 17

Actual results

The green dot does not disappear, even after disposing of any controller in the camera view.

About your device

Brand Model OS
Apple iPhone 12 14.4

BLKKKBVSIK avatar Mar 02 '21 16:03 BLKKKBVSIK

Any update on this?

akshatjagga avatar Mar 11 '21 21:03 akshatjagga

Same on OnePlus 7 Pro (Android), the Pop-up front camera stays up after navigate to another screen Any fix for this ?

theogrillat avatar Mar 16 '21 03:03 theogrillat

Any information on when this bug will be fixed ? @g-apparence

BLKKKBVSIK avatar Mar 31 '21 15:03 BLKKKBVSIK

Hello, sorry I'm quite really busy this month. The problem is that we keep the state of the camera while you navigate. If you really want to force the camera to close you have to :

  • replace the current pushed page
  • force the previous page to close the camera before navigating (just remove the CamerAwesome preview from your page before navigating)

As CamerAwesome is started with your view this behavior is totally "normal". We can think of a way to make it better. If you have any suggestions on what you want I'm open.

g-apparence avatar Apr 01 '21 07:04 g-apparence

I tried to work around this using WidgetsBinding.instance.addObserver(this) and implementing didChangeAppLifecycleState. If the AppLifecycleState is anything other than resumed, I call CamerawesomePlugin.stop() - and the indicator light goes out. On resume I call `CamerawesomePlugin.start()', and it works OK.

I'm working on a problem I see the first time the app is executed. It pauses to ask for camera permissions, when they are granted I see this error:

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(CAMERA_MUST_BE_INIT, init must be call before start, , null)

I'll continue investigating, and will post results here.

adrian-brennan avatar Mar 18 '22 01:03 adrian-brennan

Looks like the plugin is in a weird state the very first time the camera is used (when it's asking for permission). CamerawesomePlugin.currentState is STOPPED, but calling start() gives the error I mentioned.

So I implemented the AppLifecycle state as described above, stopping and starting the plugin as the app lifecycle changes, except I don't call start() when the lifecycle change is immediately after the permission grant.

That works fine: first time startup behaves as expected, and now use of the camera (and the indicator light) correctly follows the app state.

adrian-brennan avatar Mar 18 '22 02:03 adrian-brennan

This seems like an easy fix at first sight.

Sorry I don't have time right now to take a look, but I keep this in "to do".

g-apparence avatar Mar 24 '22 21:03 g-apparence

this makes the battery wasteful, because the camera is open again after dispose. both on android and on ios. i added the following code on the screen after open camera,

  Future.delayed( const Duration( seconds: 1), () {
     CamerawesomePlugin.stop();
  });

ZaenalMuzaqqi avatar Aug 24 '23 03:08 ZaenalMuzaqqi