cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zia Sergio (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-12335) captureVideo() crashes the app when running to an android 6.0 or 7.0 emulator
Date Tue, 10 Jan 2017 12:32:58 GMT

    [ https://issues.apache.org/jira/browse/CB-12335?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15814854#comment-15814854
] 

Zia Sergio commented on CB-12335:
---------------------------------

I have found a solution to resolve the first problem detected using an android 6.0 emulator.

Here is my modified captureVideo() function :

{code:title=Capture.java}
    private void captureVideo(Request req) {
        boolean needExternalStoragePermission =
                !PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);

        boolean needCameraPermission = cameraPermissionInManifest &&
                !PermissionHelper.hasPermission(this, Manifest.permission.CAMERA);

        if (needExternalStoragePermission || needCameraPermission) {
            if (needExternalStoragePermission && needCameraPermission) {
                PermissionHelper.requestPermissions(this, req.requestCode, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.CAMERA});
            } else if (needExternalStoragePermission) {
                PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.READ_EXTERNAL_STORAGE);
            } else {
                PermissionHelper.requestPermission(this, req.requestCode, Manifest.permission.CAMERA);
            }
        } else {
            Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);

            if(Build.VERSION.SDK_INT > 7){
                intent.putExtra("android.intent.extra.durationLimit", req.duration);
                intent.putExtra("android.intent.extra.videoQuality", req.quality);
            }
            this.cordova.startActivityForResult((CordovaPlugin) this, intent, req.requestCode);
        }
    }
{code}

The second problem seems related to the virtual camera of the android 7.0 emulator.
I had the opportunity to check using an android 7.1 Nexus device and the video capture works
fine ! (using the modified function above)

> captureVideo() crashes the app when running to an android 6.0 or 7.0 emulator
> -----------------------------------------------------------------------------
>
>                 Key: CB-12335
>                 URL: https://issues.apache.org/jira/browse/CB-12335
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Media Capture
>            Reporter: Zia Sergio
>
> cordova 6.4
> cordova android platform 6.0
> cordova-media-capture plugin 1.4.1
> built : android sdk version 24
> When using Android 6.0 emulator :
> target Android 6.0 - API Level 23
> cpu Intel Atom (x86_64)
> front and back camera emulated
> memory RAM 1024
> VM heap 64
> internal storage 16 GiB
> SD card 4 GiB
> The emulated camera starts recording a video, stops correctly, but crashes the app when
validate the captured video.
> {code:title=adb logcat trace}
> 01-09 11:04:55.485  1913  2552 E DatabaseUtils: Writing exception to parcel
> 01-09 11:04:55.485  1913  2552 E DatabaseUtils: java.lang.SecurityException: Permission
Denial: reading com.android.providers.media.MediaProvider uri content://media/external/video/media/40
from pid=3130, uid=10056 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
> 01-09 11:04:55.485  1913  2552 E DatabaseUtils:         at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:605)
> 01-09 11:04:55.485  1913  2552 E DatabaseUtils:         at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:480)
> 01-09 11:04:55.485  1913  2552 E DatabaseUtils:         at android.content.ContentProvider$Transport.query(ContentProvider.java:211)
> 01-09 11:04:55.485  1913  2552 E DatabaseUtils:         at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
> 01-09 11:04:55.485  1913  2552 E DatabaseUtils:         at android.os.Binder.execTransact(Binder.java:453)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime: Process: com.saipm.dh, PID: 3130
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime: java.lang.SecurityException: Permission
Denial: reading com.android.providers.media.MediaProvider uri content://media/external/video/media/40
from pid=3130, uid=10056 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:1599)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at android.content.ContentResolver.query(ContentResolver.java:491)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at android.content.ContentResolver.query(ContentResolver.java:434)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at org.apache.cordova.CordovaResourceApi.mapUriToFile(CordovaResourceApi.java:154)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at org.apache.cordova.mediacapture.Capture.createMediaFile(Capture.java:433)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at org.apache.cordova.mediacapture.Capture.onVideoActivityResult(Capture.java:413)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at org.apache.cordova.mediacapture.Capture$1.run(Capture.java:332)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
> 01-09 11:04:55.487  3130  3189 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:818)
> 01-09 11:04:55.488  1630  2026 W ActivityManager:   Force finishing activity com.saipm.dh/.MainActivity
> {code}
> When using Android 7.0 emulator :
> target Android 7.0 - API Level 24
> cpu Intel Atom (x86_64)
> front and back camera emulated
> memory RAM 1024
> VM heap 64
> internal storage 16 GiB
> SD card 8 GiB
> When captureVideo() is invoked, the emulated camera does not start and the app crashes
immediately.
> {code:title=adb logcat trace}
> 01-09 10:40:23.266  1252  1252 V EmulatedCamera_Camera: getCameraInfo
> 01-09 10:40:23.266  1252  1252 V EmulatedCamera_BaseCamera: getCameraInfo
> 01-09 10:40:23.291 28517 28534 E AndroidRuntime: FATAL EXCEPTION: Thread-2
> 01-09 10:40:23.291 28517 28534 E AndroidRuntime: Process: com.android.camera, PID: 28517
> 01-09 10:40:23.291 28517 28534 E AndroidRuntime: java.lang.NullPointerException: Attempt
to read from field 'int android.hardware.Camera$Size.width' on a null object reference
> 01-09 10:40:23.291 28517 28534 E AndroidRuntime:        at com.android.camera.VideoCamera.getDesiredPreviewSize(VideoCamera.java:799)
> 01-09 10:40:23.291 28517 28534 E AndroidRuntime:        at com.android.camera.VideoCamera.readVideoPreferences(VideoCamera.java:781)
> 01-09 10:40:23.291 28517 28534 E AndroidRuntime:        at com.android.camera.VideoCamera.-wrap3(VideoCamera.java)
> 01-09 10:40:23.291 28517 28534 E AndroidRuntime:        at com.android.camera.VideoCamera$1.run(VideoCamera.java:389)
> 01-09 10:40:23.291 28517 28534 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:761)
> 01-09 10:40:23.293  1503  1514 W ActivityManager:   Force finishing activity com.android.camera/.VideoCamera
> 01-09 10:40:23.295  1503  1514 W ActivityManager:   Force finishing activity com.saipm.dh/.MainActivity
> 01-09 10:40:23.322 28517 28528 I art     : Background sticky concurrent mark sweep GC
freed 8683(640KB) AllocSpace objects, 4(80KB) LOS objects, 0% free
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message