Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25265] Android: OpenPhotoGallery crash when i try to select images with small cloud icon(not backup)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-08-30T02:44:04.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
Reporterboaz@e-drivetech.com
AssigneeUnknown
Created2017-09-11T13:44:44.000+0000
Updated2018-08-30T02:44:04.000+0000

Description

app freezes and crashes without errors when using openPhotoGallery and selecting images with small cloud icon. Those images are part of the device storage and not yet back up. When pressing on images with no backup cloud icon it works well and i get to the success callback event 6.1.2.GA Below used function. var buttonGallery = Titanium.UI.createButton({ title:"Open the photo gallery", width:180, height:48, bottom: 12, zIndex:2 }); buttonGallery.addEventListener("click", function(e){ //obtain an image from the gallery Titanium.Media.openPhotoGallery({ success:function(event) { alert('1'); }, error:function(error) { //set message if (error.code == Titanium.Media.NO_CAMERA) { alert('No Cam'); } else { alert('error'); } }, cancel:function() { //user cancelled the action fron within //the photo gallery } }); });

Comments

  1. Hans Knöchel 2017-09-12

    Hey there, is this iOS or Android? Please always indicate the platform and complete environment (CLI-version, SDK-version, platform, platform version). Also, any idea how to test this? Connect with iCloud and try to access it before it's synced? I feel, if it's an iOS issue, it's rather an edge-case on iOS that is not handled properly, since it shouldn't even show up in the media-picker then.
  2. boaz@e-drivetech.com 2017-09-13

    Android Samsung 7 edge Latest cli and sdk 6.2.2
  3. Joshua Quick 2017-09-13

    [~boaz@e-drivetech.com], can you tell us which photo gallery app was opened please? That is, did it look like Google's standard gallery app? Or a custom one from Samsung? Or did you do a photo selection from another app such as GoogleDrive, DropBox, OneDrive, etc.? (I ask because photo selection can default to 3rd party apps.) Also, if you can provide us the logged Android error messages, then that might help us isolate the issue. Thanks!
  4. David Jones 2018-02-28

    We are experiencing this issue as well: Android 7.0 SDK: 7.0.2.GA When we call Ti.Media.openPhotoGallery, it opens up the Gallery of "Recent" photos and auto-slides out the menu drawer to let us select between "Downloads", "Phone", "Google Drive", "Dropbox", etc... When we select the "Dropbox" option, it opens dropbox, we select the desired file, and dropbox displays a "downloading" ux. Shortly after downloading (presumably when resuming our app with the selected image result) we get the following crash w/ stack trace:
       [ERROR] CursorWindow: Failed to read row 0, column 1 from a CursorWindow which has 1 rows, 1 columns.
       [WARN]  SystemReader: Cannot find supportKddiAuNaming, use default value instead
       [ERROR] TiApplication: (main) [45861,105353] Sending event: exception on thread: main msg:java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content: typ=image/png flg=0x3 }} to activity {com.example/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.; Titanium 7.0.2,2018/02/09 10:59,undefined
       [ERROR] TiApplication: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content: typ=image/png flg=0x3 }} to activity {com.example/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
       [ERROR] TiApplication:  at android.app.ActivityThread.deliverResults(ActivityThread.java:4297)
       [ERROR] TiApplication:  at android.app.ActivityThread.handleSendResult(ActivityThread.java:4347)
       [ERROR] TiApplication:  at android.app.ActivityThread.-wrap20(ActivityThread.java)
       [ERROR] TiApplication:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
       [ERROR] TiApplication:  at android.os.Handler.dispatchMessage(Handler.java:102)
       [ERROR] TiApplication:  at android.os.Looper.loop(Looper.java:173)
       [ERROR] TiApplication:  at android.app.ActivityThread.main(ActivityThread.java:6459)
       [ERROR] TiApplication:  at java.lang.reflect.Method.invoke(Native Method)
       [ERROR] TiApplication:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:938)
       [ERROR] TiApplication:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828)
       [ERROR] TiApplication: Caused by: java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
       [ERROR] TiApplication:  at android.database.CursorWindow.nativeGetString(Native Method)
       [ERROR] TiApplication:  at android.database.CursorWindow.getString(CursorWindow.java:460)
       [ERROR] TiApplication:  at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
       [ERROR] TiApplication:  at android.database.CursorWrapper.getString(CursorWrapper.java:142)
       [ERROR] TiApplication:  at org.appcelerator.titanium.io.TitaniumBlob.init(TitaniumBlob.java:86)
       [ERROR] TiApplication:  at org.appcelerator.titanium.io.TitaniumBlob.<init>(TitaniumBlob.java:33)
       [ERROR] TiApplication:  at org.appcelerator.titanium.io.TiFileFactory.createTitaniumFile(TiFileFactory.java:85)
       [ERROR] TiApplication:  at ti.modules.titanium.media.MediaModule.createImageData(MediaModule.java:1061)
       [ERROR] TiApplication:  at ti.modules.titanium.media.MediaModule.createDictForImage(MediaModule.java:1055)
       [ERROR] TiApplication:  at ti.modules.titanium.media.MediaModule$1.onResult(MediaModule.java:1009)
       [ERROR] TiApplication:  at org.appcelerator.titanium.util.TiActivitySupportHelper$1.onResult(TiActivitySupportHelper.java:60)
       [ERROR] TiApplication:  at org.appcelerator.titanium.util.TiActivitySupportHelper.onActivityResult(TiActivitySupportHelper.java:113)
       [ERROR] TiApplication:  at org.appcelerator.titanium.TiBaseActivity.onActivityResult(TiBaseActivity.java:793)
       [ERROR] TiApplication:  at android.app.Activity.dispatchActivityResult(Activity.java:6926)
       [ERROR] TiApplication:  at android.app.ActivityThread.deliverResults(ActivityThread.java:4293)
       [ERROR] TiApplication:  ... 9 more
       
  5. David Jones 2018-03-02

    More Info: I tried an alternative approach as a possible workaround but also ran into a similiar issue. The general idea for this workaround was to: 1) Launch an intent directly with the ACTION_GET_CONTENT action to pick an image (ultimately from dropbox) 2) Upon success, we get a uri from dropbox contained in e.intent.data like: content://com.dropbox.android.FileCache/filecache/441c518d-c217-466b-8f6c-541d1b831f9a (this file had just been selected in dropbox ux and downloaded to device) 3) Copy the content to a file in our app temp directory using Ti.Filesystem.getFile and copy() to effectively resolve the content uri and make a copy for us in our temp folder that we can access normally to get the image CODE:
       var intent = Titanium.Android.createIntent({
           action : Ti.Android.ACTION_GET_CONTENT,
           type : "image/*"
       });
       
       intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
       Ti.Android.currentActivity.startActivityForResult(intent, function(e) {
           if(e.intent && e.intent.data) {
               //Make a copy of the file into our app temp dir to automatically resolve any "content://" uri path
               var imageSourceFile = Ti.Filesystem.getFile(e.intent.data);
               var imageCopyFile = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, imageSourceFile.name);
               imageSourceFile.copy(imageCopyFile.nativePath);
               var imageBlob = imageCopyFile.read();
       
               //Release file handles
               imageSourceFile = null;
               imageCopyFile = null;
       
               return onMediaSuccess({
                   media: imageBlob
               });
           }
       });
       
    However we encountered a similiar exception when we called
           var imageSourceFile = Ti.Filesystem.getFile(e.intent.data);
           //e.intent.data is 'content://com.dropbox.android.FileCache/filecache/441c518d-c217-466b-8f6c-541d1b831f9a'
       
    Here is the exception: {noformat} [ERROR] CursorWindow: Failed to read row 0, column 1 from a CursorWindow which has 1 rows, 1 columns. [WARN] W/System.err: java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. [WARN] W/System.err: at android.database.CursorWindow.nativeGetString(Native Method) [WARN] W/System.err: at android.database.CursorWindow.getString(CursorWindow.java:460) [WARN] W/System.err: at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51) [WARN] W/System.err: at android.database.CursorWrapper.getString(CursorWrapper.java:142) [WARN] W/System.err: at org.appcelerator.titanium.io.TitaniumBlob.init(TitaniumBlob.java:86) [WARN] W/System.err: at org.appcelerator.titanium.io.TitaniumBlob.(TitaniumBlob.java:33) [WARN] W/System.err: at org.appcelerator.titanium.io.TiFileFactory.createTitaniumFile(TiFileFactory.java:85) [WARN] W/System.err: at org.appcelerator.titanium.util.TiUrl.resolve(TiUrl.java:258) [WARN] W/System.err: at org.appcelerator.kroll.KrollProxy.resolveUrl(KrollProxy.java:1321) [WARN] W/System.err: at org.appcelerator.titanium.TiFileProxy.(TiFileProxy.java:80) [WARN] W/System.err: at ti.modules.titanium.filesystem.FileProxy.(FileProxy.java:18) [WARN] W/System.err: at ti.modules.titanium.filesystem.FilesystemModule.getFile(FilesystemModule.java:85) [WARN] W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method) [WARN] W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:57) [WARN] W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:43) [WARN] W/System.err: at org.appcelerator.kroll.runtime.v8.V8Function$1.run(V8Function.java:70) [WARN] W/System.err: at android.os.Handler.handleCallback(Handler.java:751) [WARN] W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) [WARN] W/System.err: at android.os.Looper.loop(Looper.java:173) [WARN] W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6459) [WARN] W/System.err: at java.lang.reflect.Method.invoke(Native Method) [WARN] W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:938) [WARN] W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:828) [ERROR] TiExceptionHandler: (main) [17254,128066] ----- Titanium Javascript Runtime Error ----- [ERROR] TiExceptionHandler: (main) [0,128066] - In ti:/invoker.js:101,19 [ERROR] TiExceptionHandler: (main) [0,128066] - Message: Uncaught Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. [ERROR] TiExceptionHandler: (main) [0,128066] - Source: return delegate.apply(invoker.__thisObj__, args); [WARN] SystemReader: Cannot find supportKddiAuNaming, use default value instead [ERROR] V8Exception: Exception occurred at ti:/invoker.js:101: Uncaught Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. [ERROR] V8Exception: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. {noformat}
  6. Joshua Quick 2018-08-30

    Everyone, the cloud photo selection issues are fixed in Titanium 7.3.0. When we added support for video selection in [TIMOB-24707], we ended up resolving the "content://" URL scheme issues we had.

JSON Source