Skip to content
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

Camera plugin silently crashes when call takePicture() immediately after stopImageStream(); #30680

Closed
yfer opened this issue Apr 8, 2019 · 6 comments
Labels
c: crash Stack traces logged to the console p: camera The camera plugin package flutter/packages repository. See also p: labels. platform-android Android applications specifically

Comments

@yfer
Copy link

yfer commented Apr 8, 2019

When i was writing my app for Flutter Create contest i've notices a strange bug.
I am not sure if i can provide full source code for good reproducing of it until challenge results aired. ( Will be nice to have an answer from somebody from a challenge team, so i put source code on github )

Crash appears on Pixel 1(only backwards camera) and Xiaomi A2(all cameras) phones.
If i try to takePicture imidiately after stopImageStream then plugin silently crashes with a java NullReference message (i'll provide a bit later). And picture not taken.

But when i insert some delay between calls, then everything is alright.

It seems like not all necessary resources are disposed when call to stopImageStream ends.
And something more strange, not all devices are behaving like this. And even on one device (Google Pixel 1) frontal camera was ok, but backward - throws.

...
// when controller startImageStreem executed
await cameraController.startImageStream(...)
...
// this crashes
await cameraController.stopImageStream();
await cameraController.takePicture(p); //here
// and this works fine
await cameraController.stopImageStream();
await Future.delayed(Duration(seconds:1)); // ! some resources are successfully disposed during this delay
await cameraController.takePicture(p);
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17134.648], locale en-US)
    • Flutter version 1.2.1 at c:\flutter
    • Framework revision 8661d8aecd (7 weeks ago), 2019-02-14 19:19:53 -0800
    • Engine revision 3757390fa4
    • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\Yfer\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 34.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[√] IntelliJ IDEA Ultimate Edition (version 2017.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2017.3.4
    • Flutter plugin version 22.2.2
    • Dart plugin version 173.4548.30

[√] VS Code (version 1.31.0)
    • VS Code at C:\Users\Yfer\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 2.22.3

[!] Connected device
    ! No devices available
@kf6gpe kf6gpe added p: camera The camera plugin platform-android Android applications specifically c: crash Stack traces logged to the console labels Jun 24, 2019
@kf6gpe kf6gpe added the plugin label Jan 6, 2020
@TahaTesser
Copy link
Member

Hi @yfer
Are you still experiencing this issue?
Thank you

@TahaTesser TahaTesser added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 3, 2020
@jmagman
Copy link
Member

jmagman commented Mar 24, 2020

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.

@jmagman jmagman closed this as completed Mar 24, 2020
@antogalli
Copy link

I got the same problem, i can't find a solution.
I Added permissions too into manifest (CAMERA and WRITE_EXTERNAL_STORAGE) but i still got the crash:

JNI critical lock held for 21.299ms on Thread[13,tid=24836,Runnable,Thread*=0xd32b6a00,peer=0x12dc0300,"Binder:24813_1"

@antogalli
Copy link

antogalli commented Dec 29, 2020

I solved on the emulator upgrading NDK and setting the camera on "Emulated" and not on "Virtual Scene".

@pedromassangocode pedromassangocode removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 30, 2020
@amzahrani
Copy link

I am facing the same issue.

@github-actions
Copy link

github-actions bot commented Aug 6, 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 Aug 6, 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
c: crash Stack traces logged to the console p: camera The camera plugin package flutter/packages repository. See also p: labels. platform-android Android applications specifically
Projects
None yet
Development

No branches or pull requests

7 participants