NativeScript / nativescript-camera

NativeScript plugin to empower using device camera.
Apache License 2.0
93 stars 47 forks source link

Crash opening camera on Huawei Mediapad T5 #243

Closed tommag21 closed 4 years ago

tommag21 commented 4 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

The NS-Vue demo of this plugin and this app:

Please, tell us how to recreate the issue in as much detail as possible.

When I open the camera, the NativeScript activity restarts in the background, showing the splash page and the first page. On the demo app it happens about 15% of the times, on my app about 90%.

Debug stops here and this event handler is never called. The plugin works fine on other devices and emulators.

Full device logs: output.txt

Is there any code involved?

async addIdDocument() {
    try {
        await camera.requestCameraPermissions();
        let asset = await camera.takePicture({ width: 1024, height: 1024, keepAspectRatio: true }); // same result without options parameter
        this.idDocument = await ImageSource.fromAsset(asset);
    } catch (e) {
        if (e.message === "cancelled") return;
        this.$snackbar(this.$options.filters.L("newRecupero.fotocameraError"), "error");
        console.log(e);
    }
}
RGBvision commented 4 years ago

Same issue on various Android devices (Android 6 - 9). One or two seconds after photo has been taken and appears on Image component App returns to start page.

tommag21 commented 4 years ago

@RGBvision what NativeScript version are you using?

RGBvision commented 4 years ago

@tommag21 tns-core-modules 6.5.1, tns-android 6.5.0

RGBvision commented 4 years ago

I found that when you open the camera and don't take a photo, just press back button, the entire history of navigation is lost. Start page will be open. Looks like app restarting anyway.

tommag21 commented 4 years ago

I am experiencing the same bug on the demo-vue app, plus another one which might be related.

The more photos I take, the slower the app gets, until it crashes. It takes about 4-5 snaps.

Logs: debug-demo.txt

I found that when you open the camera and don't take a photo, just press back button, the entire history of navigation is lost. Start page will be open. Looks like app restarting anyway.

From what I've seen the crash happens when the camera is opened, before the photo is taken.

tommag21 commented 4 years ago

Might be related to this: White screen, no crash, logged ClassNotFoundException OnUnhandledKeyEventListener

tommag21 commented 4 years ago

After further investigation I have concluded that it's a low memory issue. On some devices like the Huawei Mediapad T5, opening the camera causes the sistem to sometimes kill background apps, including the one launching the camera intent. The taken photo is still saved at these paths, so I edited the plugin code to save the path to application settings, retrieving the photo after the app has restarted.