cordova-plugin-camera-preview icon indicating copy to clipboard operation
cordova-plugin-camera-preview copied to clipboard

Crashes app on Android when used with Cordova Screen Orientation Plugin

Open WeaponX86 opened this issue 8 years ago • 6 comments

Phonegap version: cli-7.0.1 android-minSdkVersion: 14 android-targetSdkVersion: 26 cordova-plugin-screen-orientation version: 2.0.1 cordova-plugin-camera-preview: 0.9.0

Device: Google Pixel Android version: 8.0.0

Crashes only after calling screen.orientation.lock() and subsequently pausing or minimizing the app. Retrieving the screen orientation doesn't seem to cause issues. screenshot_20171010-153242

WeaponX86 avatar Oct 10 '17 19:10 WeaponX86

@WeaponX86 Hi, I have an app where cordova-plugin-camera-preview is working together with cordova-plugin-screen-orientation.

First of all the current version of cordova-plugin-screen-orientation seems to be 2.0.2. Please update the plugin and try again. Maybe it was a temporary problem.

If not, here is a sample source code that works for me

document.addEventListener('deviceready', function() {
    screen.orientation.lock('landscape');

    CameraPreview.startCamera({}, function() {
        alert('camera started succesfully');
    }, function(_error) {
        alert('camera could not be started. ' + _error);
    });
}, false);

This short snippet is not tested under Android 8 but the aforementioned app is working with a source code similar to the above.

Also. Did you use the cordova-plugin-camera-sample-app from github? Last time I checked it was heavily outdated and many features did not work correctly.

regards Choppel

Choppel avatar Nov 24 '17 15:11 Choppel

I just tested again with cordova-plugin-screen-orientation version 2.0.2 and the latest version of the camera preview and it always crashes when I pause the app after calling screen.orientation.lock.

Here is my config.xml: https://pastebin.com/BZ2MJiPm

WeaponX86 avatar Dec 06 '17 20:12 WeaponX86

@WeaponX86 It seems this issue only applies to your app which seems to be large, looking at the config.xml. No one else seems to have that problem. So I advise you to refactor your code. Every time I had a problem that no one else had, this resolved the issue for me.

Choppel avatar Dec 18 '17 10:12 Choppel

@WeaponX86 I am having this issue as well.

iisdan avatar Jan 11 '18 20:01 iisdan

@WeaponX86 @iisdan Hi, there seem to be different problems with the master version from github. Please try the version 0.9.0 directly from npm instead.

Choppel avatar Jan 12 '18 08:01 Choppel

I am also facing the same issue. I am using screen orientation plugin to detect the device orientation. when the camera is open and if I put the app in background when it is in landscape mode and bringing back the app to foreground multiple times result to application crash. the device i am using for testing is Redmi Note 5. Attaching screenshots.

screenshot_2018-09-26-14-45-23-440_com miui home 1

screenshot_2018-09-26-14-45-36-969_com miui bugreport 1

sumitk91 avatar Sep 26 '18 09:09 sumitk91