Avoid stackoverflows on zoom/ev, fixes #856

pull/953/head
Mattia Iavarone 5 years ago
parent 9c86ffa750
commit 71177d9f2a
  1. 10
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java
  2. 10
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java

@ -623,7 +623,10 @@ public class Camera1Engine extends CameraBaseEngine implements
public void setZoom(final float zoom, @Nullable final PointF[] points, final boolean notify) {
final float old = mZoomValue;
mZoomValue = zoom;
mZoomTask = getOrchestrator().scheduleStateful("zoom (" + zoom + ")",
// Zoom requests can be high frequency (e.g. linked to touch events), so
// we remove the task before scheduling to avoid stack overflows in orchestrator.
getOrchestrator().remove("zoom");
mZoomTask = getOrchestrator().scheduleStateful("zoom",
CameraState.ENGINE,
new Runnable() {
@Override
@ -655,8 +658,11 @@ public class Camera1Engine extends CameraBaseEngine implements
@Nullable final PointF[] points, final boolean notify) {
final float old = mExposureCorrectionValue;
mExposureCorrectionValue = EVvalue;
// EV requests can be high frequency (e.g. linked to touch events), so
// we remove the task before scheduling to avoid stack overflows in orchestrator.
getOrchestrator().remove("exposure correction");
mExposureCorrectionTask = getOrchestrator().scheduleStateful(
"exposure correction (" + EVvalue + ")",
"exposure correction",
CameraState.ENGINE,
new Runnable() {
@Override

@ -1246,8 +1246,11 @@ public class Camera2Engine extends CameraBaseEngine implements
public void setZoom(final float zoom, final @Nullable PointF[] points, final boolean notify) {
final float old = mZoomValue;
mZoomValue = zoom;
// Zoom requests can be high frequency (e.g. linked to touch events), so
// we remove the task before scheduling to avoid stack overflows in orchestrator.
getOrchestrator().remove("zoom");
mZoomTask = getOrchestrator().scheduleStateful(
"zoom (" + zoom + ")",
"zoom",
CameraState.ENGINE,
new Runnable() {
@Override
@ -1302,8 +1305,11 @@ public class Camera2Engine extends CameraBaseEngine implements
final boolean notify) {
final float old = mExposureCorrectionValue;
mExposureCorrectionValue = EVvalue;
// EV requests can be high frequency (e.g. linked to touch events), so
// we remove the task before scheduling to avoid stack overflows in orchestrator.
getOrchestrator().remove("exposure correction");
mExposureCorrectionTask = getOrchestrator().scheduleStateful(
"exposure correction (" + EVvalue + ")",
"exposure correction",
CameraState.ENGINE,
new Runnable() {
@Override

Loading…
Cancel
Save