Android video capture: release() allocated ImageReader surfaces |
||||
Issue descriptionVideoCaptureCamera2 uses an ImageReader, whose Surface is used in 4 places [1]. (Actually is also used in ScreenCapture.java [1b]). android.viewSurface objects need to be explicitly release()d when finished with, as stated in [2]. I also saw some warnings in the logcat when restarting capture, hence this bug. [1] https://cs.chromium.org/search/?q=VideoCaptureCamera2.java+getSurface&sq=package:chromium&type=cs [1b] https://cs.chromium.org/chromium/src/media/capture/content/android/java/src/org/chromium/media/ScreenCapture.java?q=capture+getSurface%5C(%5C)&sq=package:chromium&l=320&dr=C [2] https://developer.android.com/reference/android/view/Surface.html#release()
,
Sep 3 2016
Correction: it's used in 4 places in VideoCaptureCamera2.java, but only two such Surfaces are actually allocated and need to be release()d.
,
Sep 4 2017
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Sep 8 2017
Brave, is this still relevant?
,
Sep 15 2017
I guess so, as no change has been made so far. Wondering what's the warning message and what's worst consequence this can make?
,
Nov 8 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e123c3a6ce3da470ef94755cb5b7bfcc7e4fe7a4 commit e123c3a6ce3da470ef94755cb5b7bfcc7e4fe7a4 Author: Weiyong Yao <braveyao@chromium.org> Date: Wed Nov 08 01:00:03 2017 [Android Camera capture]: call release() when a Surface is done. VideoCaptureCamera2 doesn't release the Surface reference, |mPrecaptureSurface|, when it's done, which will cause system error. Some related logs as below: E StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. E StrictMode: java.lang.Throwable: Explicit termination method 'release' not called E StrictMode: at org.chromium.media.VideoCaptureCamera2. createPreviewObjectsAndCaptureSession(VideoCaptureCamera2.java:345) This cl is to release |mPrecaptureSurface| when capture is done. The ImageReader mentioned in the crbug643884 seems not causing any problem. But it's still better to call their close() at the end. Bug: 643884 Change-Id: I969fd778f33946ca6a9637001a9190d4eb71bcfb Reviewed-on: https://chromium-review.googlesource.com/757696 Reviewed-by: Emircan Uysaler <emircan@chromium.org> Commit-Queue: Weiyong Yao <braveyao@chromium.org> Cr-Commit-Position: refs/heads/master@{#514688} [modify] https://crrev.com/e123c3a6ce3da470ef94755cb5b7bfcc7e4fe7a4/media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera2.java
,
Nov 8 2017
During debugging other issues on Pixel with Android 8.1, I got below error logs: 10-06 10:24:47.590 11955 11965 E StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. 10-06 10:24:47.590 11955 11965 E StrictMode: java.lang.Throwable: Explicit termination method 'release' not called 10-06 10:24:47.590 11955 11965 E StrictMode: at dalvik.system.CloseGuard.open(CloseGuard.java:223) 10-06 10:24:47.590 11955 11965 E StrictMode: at android.view.Surface.setNativeObjectLocked(Surface.java:554) 10-06 10:24:47.590 11955 11965 E StrictMode: at android.view.Surface.<init>(Surface.java:187) 10-06 10:24:47.590 11955 11965 E StrictMode: at org.chromium.media.VideoCaptureCamera2.createPreviewObjectsAndCaptureSession(VideoCaptureCamera2.java:345) 10-06 10:24:47.590 11955 11965 E StrictMode: at org.chromium.media.VideoCaptureCamera2.access$200(VideoCaptureCamera2.java:53) 10-06 10:24:47.590 11955 11965 E StrictMode: at org.chromium.media.VideoCaptureCamera2$CrStateListener.onOpened(VideoCaptureCamera2.java:60) 10-06 10:24:47.590 11955 11965 E StrictMode: at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:139) 10-06 10:24:47.590 11955 11965 E StrictMode: at android.os.Handler.handleCallback(Handler.java:790) 10-06 10:24:47.590 11955 11965 E StrictMode: at android.os.Handler.dispatchMessage(Handler.java:99) 10-06 10:24:47.590 11955 11965 E StrictMode: at android.os.Looper.loop(Looper.java:164) 10-06 10:24:47.590 11955 11965 E StrictMode: at android.app.ActivityThread.main(ActivityThread.java:6494) 10-06 10:24:47.590 11955 11965 E StrictMode: at java.lang.reflect.Method.invoke(Native Method) 10-06 10:24:47.590 11955 11965 E StrictMode: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 10-06 10:24:47.590 11955 11965 E StrictMode: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 10-06 10:24:47.591 712 1094 I Camera2ClientBase: Closed Camera 1. Client was: org.chromium.chrome (PID 11955, UID 10138) Can't find any error logs related to the surface allocated with ImageReader methods. It's harmless to call ImageReader.close() method at the end though. Mark this as fixed. |
||||
►
Sign in to add a comment |
||||
Comment 1 by mcasas@chromium.org
, Sep 3 2016