Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b289ca8 authored by Mark Harman's avatar Mark Harman
Browse files

Fix crash with RAW in some cases due to threading issue when "Pause after taking photo" enabled.

parent 68f48867
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ Version 1.44.1 (Work in progress)

FIXED   Crash in 1.44 for ghost image option if selected image could not be loaded due to
        SecurityException.
FIXED   Crash with RAW (DNG) in some cases due to threading issue when "Pause after taking photo"
        enabled.

Version 1.44 (2018/09/18)

+32 −12
Original line number Diff line number Diff line
@@ -2818,7 +2818,19 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
		View shareButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.share);
		// trash/share only shown when preview is paused after taking a photo
		boolean pause_preview =  sharedPreferences.getBoolean(PreferenceKeys.PausePreviewPreferenceKey, false);
		if( pause_preview ) {
            assertFalse(mPreview.isPreviewStarted());
            assertTrue(switchCameraButton.getVisibility() == View.GONE);
            assertTrue(switchVideoButton.getVisibility() == View.GONE);
            assertTrue(exposureButton.getVisibility() == View.GONE);
            assertTrue(exposureLockButton.getVisibility() == View.GONE);
            assertTrue(audioControlButton.getVisibility() == View.GONE);
            assertTrue(popupButton.getVisibility() == View.GONE);
            assertTrue(trashButton.getVisibility() == View.VISIBLE);
            assertTrue(shareButton.getVisibility() == View.VISIBLE);
        }
        else {
            assertTrue(mPreview.isPreviewStarted()); // check preview restarted
            assertTrue(switchCameraButton.getVisibility() == View.VISIBLE);
            assertTrue(switchVideoButton.getVisibility() == View.VISIBLE);
@@ -2831,6 +2843,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
            assertTrue(trashButton.getVisibility() == View.GONE);
            assertTrue(shareButton.getVisibility() == View.GONE);
        }
	}
	/*
	 * Note that we pass test_wait_capture_result as a parameter rather than reading from the activity, as for some reason this sometimes resets to false?! Declaring it volatile doesn't fix the problem.
@@ -3020,6 +3033,13 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
		mPreview.getCameraController().test_wait_capture_result = true;
		subTestTakePhoto(false, false, true, true, false, false, true, true);
		// now repeat with pause preview (guards against crash fixed in 1.44.1 where we got CalledFromWrongThreadException when
		// setting visibility for icons with pause preview mode with test_wait_capture_result
		editor = settings.edit();
		editor.putBoolean(PreferenceKeys.PausePreviewPreferenceKey, true);
		editor.apply();
		subTestTakePhoto(false, false, true, true, false, false, true, true);
	}
	/** Test taking multiple RAW photos.
+13 −2
Original line number Diff line number Diff line
@@ -1098,8 +1098,18 @@ public class CameraController2 extends CameraController {
				if( image != null ) {
					if( MyDebug.LOG )
						Log.d(TAG, "can now process the image");
					// should call processImage() on UI thread, to be consistent with onImageAvailable()->processImage()
					// important to avoid crash when pause preview is option, tested in testTakePhotoRawWaitCaptureResult()
					final Activity activity = (Activity)context;
					activity.runOnUiThread(new Runnable() {
						@Override
						public void run() {
							if( MyDebug.LOG )
								Log.d(TAG, "setCaptureResult UI thread call processImage()");
							processImage();
						}
					});
				}
			}
		}
		
@@ -1166,7 +1176,7 @@ public class CameraController2 extends CameraController {
				return;
			}
			synchronized( image_reader_lock ) {
				// see comment above in setCaptureResult() for why we sychonize
				// see comment above in setCaptureResult() for why we synchronize
				image = reader.acquireNextImage();
				processImage();
			}
@@ -6472,6 +6482,7 @@ public class CameraController2 extends CameraController {
				test_capture_results++;
				modified_from_camera_settings = false;
				if( onRawImageAvailableListener != null ) {
				    //test_wait_capture_result = true;
					if( test_wait_capture_result ) {
						// for RAW capture, we require the capture result before creating DngCreator
						// but for testing purposes, we need to test the possibility where onImageAvailable() for