pull/696/head
Mattia Iavarone 6 years ago
parent d54cfbbead
commit e6f599d67e
  1. 3
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java
  2. 12
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java

@ -275,7 +275,7 @@ public class Camera1Engine extends CameraEngine implements
throw new RuntimeException("Unknown CameraPreview output class.");
}
} catch (IOException e) {
LOG.e("unbindFromSurface", "Could not release surface", e);
LOG.e("onStopBind", "Could not release surface", e);
}
return Tasks.forResult(null);
}
@ -289,6 +289,7 @@ public class Camera1Engine extends CameraEngine implements
mOrchestrator.remove(JOB_FOCUS_END);
if (mCamera != null) {
try {
// In certain states, this release() call can take up to various seconds.
LOG.i("onStopEngine:", "Clean up.", "Releasing camera.");
mCamera.release();
LOG.i("onStopEngine:", "Clean up.", "Released camera.");

@ -250,7 +250,8 @@ public abstract class CameraEngine implements
private static class NoOpExceptionHandler implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(@NonNull Thread thread, @NonNull Throwable throwable) {
// No-op.
LOG.w("EXCEPTION:", "In the NoOpExceptionHandler, probably while destroying.",
"Thread:", thread, "Error:", throwable);
}
}
@ -273,10 +274,11 @@ public abstract class CameraEngine implements
if (!(throwable instanceof CameraException)) {
// This is unexpected, either a bug or something the developer should know.
// Release and crash the UI thread so we get bug reports.
LOG.e("EXCEPTION:", "Unexpected exception:", throwable);
LOG.e("EXCEPTION:", "Unexpected exception! Scheduling destroy...");
mCrashHandler.post(new Runnable() {
@Override
public void run() {
LOG.e("EXCEPTION:", "Unexpected exception! Executing destroy...");
destroy();
// Throws an unchecked exception without unnecessary wrapping.
if (throwable instanceof RuntimeException) {
@ -290,7 +292,7 @@ public abstract class CameraEngine implements
}
final CameraException cameraException = (CameraException) throwable;
LOG.e("EXCEPTION:", "Received CameraException:", cameraException,
LOG.e("EXCEPTION:", "Received CameraException.",
"Engine state:", getState(), "Current thread:", Thread.currentThread());
if (fromExceptionHandler) {
// Got to restart the handler.
@ -352,9 +354,9 @@ public abstract class CameraEngine implements
}
});
try {
boolean success = latch.await(6, TimeUnit.SECONDS);
boolean success = latch.await(10, TimeUnit.SECONDS);
if (!success) {
LOG.e("DESTROY: Could not destroy synchronously after 6 seconds.",
LOG.e("DESTROY: Could not destroy synchronously after 10 seconds.",
"Current thread:", Thread.currentThread(),
"Handler thread: ", mHandler.getThread());
}

Loading…
Cancel
Save