Skip to content

[camera] Camera Timeout on some devices #76305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tomucha opened this issue Feb 18, 2021 · 30 comments
Closed

[camera] Camera Timeout on some devices #76305

Tomucha opened this issue Feb 18, 2021 · 30 comments
Assignees
Labels
e: device-specific Only manifests on certain devices p: camera The camera plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-android Android applications specifically r: timeout Issue is closed due to author not providing the requested details in time

Comments

@Tomucha
Copy link

Tomucha commented Feb 18, 2021

I have trouble with camera plugin (0.7.0+2) - the second time I try to:

  XFile file = await controller.takePicture();
  return file;

... the call ends up with "timeout". The first time I take a photo everything works fine, but all subsequent calls fail. It all happens with example application too:

https://github.com/flutter/plugins/tree/master/packages/camera/camera/example

I/flutter ( 4707): Error: captureTimeout
I/flutter ( 4707): Error Message: Picture capture request timed out
W/System  ( 4707): A resource failed to call release. 

It works on some low-level phone I have here (myPhone Hammer Iron 2).


tomucha@tomucha-mx:~$ flutter --version
Flutter 1.22.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9b2d32b605 (4 weeks ago) • 2021-01-22 14:36:39 -0800
Engine • revision 2f0af37152
Tools • Dart 2.10.5
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3)
[✓] VS Code (version 1.52.1)
[✓] Connected device (1 available)
@TahaTesser TahaTesser added the in triage Presently being triaged by the triage team label Feb 18, 2021
@TahaTesser
Copy link
Member

Hi @Tomucha
I see there's an open issue addressing the case you described. #74645
Please follow up on that issue, I'm closing the current one as a duplicate.
If you disagree, please write in the comments and I will reopen it.
Thank you

@TahaTesser TahaTesser added the r: duplicate Issue is closed as a duplicate of an existing issue label Feb 18, 2021
@Tomucha
Copy link
Author

Tomucha commented Feb 19, 2021

Hi, @TahaTesser sorry, I don't think so, please re-open :-(

#74645 is supposedly fixed by commit flutter/plugins@361567b so I applied the changes from that commit to local clone of camera 0.7.0+2 (because I cannot use non-null version). But problem is still there.

I can take the first photo, but all subsequent attempts fail. I can destroy camera controller and initialize it again, and I'm at the beginning: I can take the first photo but that's it.

I added some logging to the Camera.java and I see that "processCapture" method gets called many times and the last (hundred) calls are "case preCapture" with "aeState == 1", until it dies with CameraException(captureTimeout, Picture capture request timed out). At the beginning it goes through "case focusing" several times.

I can change whatever I want - flash mode, autofocus mode ... first photo is fine, all others fail.

//cc @mvanbeusekom

@Tomucha
Copy link
Author

Tomucha commented Feb 19, 2021

To ride the "cargo cult" wave a little bit longer, when I change:


            case preCapture:
              // Some devices might return null here, in which case we will also continue.
              if (aeState == null
                  || aeState == CaptureRequest.CONTROL_AE_STATE_PRECAPTURE
                  || aeState == CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED
                  || aeState == CaptureRequest.CONTROL_AE_STATE_CONVERGED) {
                pictureCaptureRequest.setState(State.waitingPreCaptureReady);
                setPreCaptureStartTime();
              }
              break;

to


            case preCapture:
              // Some devices might return null here, in which case we will also continue.
              if (aeState == null || aeState == 1
                  || aeState == CaptureRequest.CONTROL_AE_STATE_PRECAPTURE
                  || aeState == CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED
                  || aeState == CaptureRequest.CONTROL_AE_STATE_CONVERGED) {
                pictureCaptureRequest.setState(State.waitingPreCaptureReady);
                setPreCaptureStartTime();
              }
              break;

(aeState == 1) ... it seems to be working just fine.

Needless to say - I have no idea what that means :-)

@mvanbeusekom mvanbeusekom reopened this Feb 19, 2021
@TahaTesser TahaTesser removed the r: duplicate Issue is closed as a duplicate of an existing issue label Feb 19, 2021
@mvanbeusekom
Copy link

Thanks for the feedback @Tomucha, we will look into this. I quickly looked up what aeState == 1 means and it seems to be CONTROL_AE_STATE_SEARCHING (see here).

Now I am not yet sure how we should handle this and if simply advancing to the waitingPreCaptureReady state will solve all problems but will definitely look into it further.

@mvanbeusekom mvanbeusekom self-assigned this Feb 19, 2021
@TahaTesser TahaTesser added e: device-specific Only manifests on certain devices p: camera The camera plugin p: first party platform-android Android applications specifically and removed in triage Presently being triaged by the triage team labels Feb 19, 2021
@acoutts
Copy link

acoutts commented Feb 21, 2021

The same is happening on my pixel 4. It also takes 4-5 seconds to capture the image, does that happen on your pixel 2 as well?

@Tomucha
Copy link
Author

Tomucha commented Feb 21, 2021

@acoutts That seems like something different to me. In my case the first picture is captured quite quickly and all subsequent fail with CameraException(captureTimeout, Picture capture request timed out)

@szuwest
Copy link

szuwest commented Feb 25, 2021

I have the same problem on OPPO R11(android 8.1.1). It is always captureTimeout when I take picture.

@dinahapuque
Copy link

dinahapuque commented Feb 25, 2021

That's happening with me on Xiaomi Redmi Note 9. I can't even take the first picture after upgrading from version 0.6.0 to 0.7.0.
cameraTimeout
Picture capture request timed out

But on iPhone SE 2020 works fine.

@Tomucha
Copy link
Author

Tomucha commented Feb 25, 2021

(BTW in my case it's also after upgrade to 0.7.0, worked fine in previous versions)

@mvanbeusekom
Copy link

@szuwest, @dinahapuque, the bug related to the captureTimeout you get directly (starting from the first picture you take) should be solved as part of PR flutter/plugins#3558 (which was released with version 0.8.0-nullsafety.1).

The issue @Tomucha is having is a little bit different, I am still investigating if the suggested solution if the correct one but the issue is on the radar and I am working on it.

@szuwest
Copy link

szuwest commented Feb 26, 2021

@szuwest, @dinahapuque, the bug related to the captureTimeout you get directly (starting from the first picture you take) should be solved as part of PR flutter/plugins#3558 (which was released with version 0.8.0-nullsafety.1).

The issue @Tomucha is having is a little bit different, I am still investigating if the suggested solution if the correct one but the issue is on the radar and I am working on it.

I found that, but it is not on release branch. 0.8.0-nullsafety.1 requires on Dart 2.12 above, which my env not support now

@acoutts
Copy link

acoutts commented Feb 26, 2021

@szuwest, @dinahapuque, the bug related to the captureTimeout you get directly (starting from the first picture you take) should be solved as part of PR flutter/plugins#3558 (which was released with version 0.8.0-nullsafety.1).
The issue @Tomucha is having is a little bit different, I am still investigating if the suggested solution if the correct one but the issue is on the radar and I am working on it.

I found that, but it is not on release branch. 0.8.0-nullsafety.1 requires on Dart 2.12 above, which my env not support now

You can use null safety packages in your app before migrating - it's designed to be backwards compatible.

@szuwest
Copy link

szuwest commented Mar 1, 2021

@szuwest, @dinahapuque, the bug related to the captureTimeout you get directly (starting from the first picture you take) should be solved as part of PR flutter/plugins#3558 (which was released with version 0.8.0-nullsafety.1).

The issue @Tomucha is having is a little bit different, I am still investigating if the suggested solution if the correct one but the issue is on the radar and I am working on it.

I upgrade to 0.8.0-nullsafety.2, It still has the same problem...

@acoutts
Copy link

acoutts commented Mar 1, 2021

I've resolved this issue in my PR here- give it a try and let me know if it works for you too. Confirmed on my pixel 4.
flutter/plugins#3651

@cyanglaz cyanglaz added the P2 Important issues not at the top of the work list label Mar 4, 2021
@Tomucha
Copy link
Author

Tomucha commented Apr 7, 2021

I can confirm - the issue is still present in 0.8.1, but it seems to be fixed in flutter/plugins#3651

I have no excuse why this took me so long 👎

Thanks!!!!!

@wisnuwiry
Copy link

Are there any updates on this issue?

I am using the latest version of the camera plugin on pub.dev which is version 0.8.1 but the issue is still the same.

Log:

Picture capture request timed out

cc: @TahaTesser , @Tomucha , @mvanbeusekom

@ghost
Copy link

ghost commented May 4, 2021

CameraException(Previous capture has not returned yet., takePicture was called before the previous capture returned.)
CameraException(captureTimeout, Picture capture request timed out)
I'm also getting this issues in version 0.8.1
@TahaTesser @Tomucha @mvanbeusekom

@TahaTesser TahaTesser changed the title [Camera Plugin] Timeout on Pixel 2 [camera] Camera Timeout on some devices May 6, 2021
@wisnuwiry
Copy link

The devices that I tested had issues like the one above:

  1. Xiaomi Redmi 4X
  2. Samsung A20
  3. Samsung J2 Prime
  4. Polytron 4G502
  5. Samsung J7
  6. Samsung J2
  7. Samsung Galaxy Note 4
  8. Samsung sm n910
  9. Samsung J5 2016
  10. Sony xperia docomo

Please fix this problem immediately.

@syahnurizal
Copy link

syahnurizal commented Jun 12, 2021

I'm having same issue with the version 0.8.1 on Xiaomi MiA1 device. After calling takePicture() , device flash turn ON continuously and log return timeout

@Wian-TMC
Copy link

Consistent captureTimeout error also occurs on a Vivo 2015 smartphone running Android 10. Cannot take any pictures

@droplet-js
Copy link

any news update?

@joharputr
Copy link

still occur

@mobisolhu
Copy link

On Nokia 3.1 Plus the same problem. The last working version is 0.6.3+2. After that version always "capture timeout" error. The example app do the same.

@akshayarhata
Copy link

akshayarhata commented Aug 2, 2021

Issue Still occurs on
Redmi 6 pro, Redmi 9 Pro, Pocco m2, One plus 6
with latest version ^0.8.1+7

Is there any workaround or fix for this yet?

below are the logs:
I/Camera (18861): [FPS Range Available] is:[15, 15]
I/Camera (18861): [FPS Range Available] is:[7, 30]
I/Camera (18861): [FPS Range Available] is:[30, 30]
I/Camera (18861): [FPS Range] is:[7, 30]
E/SensorManager(18861): registerListenerImpl sensorName:BMI160_ACCELEROMETER Accelerometer Non-wakeup,isWakeUpSensor:false,callingApp: com.arhata.assetcues,callingPid:18861,callingUid:11114
W/Camera (18861): The selected imageFormatGroup is not supported by Android. Defaulting to yuv420
E/libc (18861): Access denied finding property "persist.vendor.camera.privapp.list"
W/rhata.assetcues(18861): type=1400 audit(0.0:208093): avc: denied { read } for name="u:object_r:persist_camera_prop:s0" dev="tmpfs" ino=16693 scontext=u:r:untrusted_app:s0:c90,c260,c512,c768 tcontext=u:object_r:persist_camera_prop:s0 tclass=file permissive=0
I/flutter (18861): Error: captureTimeout
I/flutter (18861): Error Message: Picture capture request timed out

@syahnurizal
Copy link

Anyone know any update on this issue? I think its quite critical since the camera is not usable at all for the affected devices

@Tomucha
Copy link
Author

Tomucha commented Aug 13, 2021

I just use camera plugin in version from this pull request:
flutter/plugins#3651

@TahaTesser
Copy link
Member

Hi @Tomucha
I cannot reproduce the issue when trying multiple Android devices with the latest camera: ^0.9.0.

The PR is mentioned is closed for similar PR flutter/plugins#3651 (comment), the issue might have been fixed in this new camera release

Can you please upgrade the package to the latest camera: ^0.9.0. and try again?

@TahaTesser TahaTesser added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 25, 2021
@Tomucha
Copy link
Author

Tomucha commented Aug 25, 2021

Sure, but not now, I have some deadlines here, so give me about 3 weeks. But I'm optimistic. It works for me when using flutter/plugins#3651

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 25, 2021
@TahaTesser TahaTesser added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 25, 2021
@darshankawar
Copy link
Member

Without additional information, we are unfortunately not sure how to resolve this issue.
We are therefore reluctantly going to close this bug for now.
Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.

Could everyone who still has this problem please file a new issue with the exact description of what happens, logs, and the output of flutter doctor -v.
All system setups can be slightly different, so it's always better to open new issues and reference related issues.

@darshankawar darshankawar added r: timeout Issue is closed due to author not providing the requested details in time and removed waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Sep 17, 2021
@github-actions
Copy link

github-actions bot commented Oct 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e: device-specific Only manifests on certain devices p: camera The camera plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-android Android applications specifically r: timeout Issue is closed due to author not providing the requested details in time
Projects
None yet
Development

No branches or pull requests