-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera] Add null check before starting preview #3127
Conversation
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent. |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
Awesome, thanks for taking over :) |
@googlebot I consent. |
@googlebot I consent. |
a16d768
to
dc2ddf8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once tests pass
177b270
to
8218ddf
Compare
Occasionally leads to NullPointerException (potentially due to some race condition, hard to reproduce deterministically). Example stack trace: E/AndroidRuntime( 5679): java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Surface android.media.ImageReader.getSurface()' on a null object reference E/AndroidRuntime( 5679): at io.flutter.plugins.camera.Camera.startPreview(Camera.java:424) E/AndroidRuntime( 5679): at io.flutter.plugins.camera.Camera$2.onOpened(Camera.java:160) E/AndroidRuntime( 5679): at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:145) E/AndroidRuntime( 5679): at android.os.Handler.handleCallback(Handler.java:883) E/AndroidRuntime( 5679): at android.os.Handler.dispatchMessage(Handler.java:100) E/AndroidRuntime( 5679): at android.os.Looper.loop(Looper.java:214) E/AndroidRuntime( 5679): at android.app.ActivityThread.main(ActivityThread.java:7356) E/AndroidRuntime( 5679): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 5679): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) E/AndroidRuntime( 5679): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
8218ddf
to
8557845
Compare
Landing per @bparrishMines's LGTM |
Adds a null reference check to make sure the pictureImageReader is not null before accessing. Also adds additional documentation to the README.md file explaining about managing App lifecycle changes in relation to the camera plugin (required since release 0.5.0 of the plugin).
Description
This pull request adds to the work of @panmari (#2965) and @Gioxxy (#2871) and adds a null reference check to make sure the
pictureImageReader
is not null before accessing. It also adds additional documentation to the README.md file explaining about managing App lifecycle changes in relation to the camera plugin (required since release 0.5.0 of the plugin).These changes have been discussed in issue flutter/flutter#19595.
Related Issues
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?