Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28193] Android: Selecting multiple photos/videos via openPhotoGallery() can cause a crash as of 9.1.0

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-10-27T21:19:03.000+0000
Affected Version/sRelease 9.1.0
Fix Version/sRelease 9.3.0, Release 9.2.2
ComponentsAndroid
Labelsandroid, media, photo, photogallery, regression, video
ReporterLokesh Choudhary
AssigneeJoshua Quick
Created2020-10-13T22:29:16.000+0000
Updated2020-10-27T21:19:03.000+0000

Description

This is a regression. Broken since 9.1.0.GA. Issue is seen only when multiple photos are selected. Selecting multiple photos from google photos does not cause this issue.

Steps to reproduce:

1. Use the code below in the app.js:
    layout: 'vertical',
    backgroundColor: 'gray'
});

galleryBtn = Ti.UI.createButton({
    title: 'Open Gallery'
});

galleryBtn.addEventListener('click', () => {
	Ti.Media.openPhotoGallery({
		allowMultiple: true,
		error: function(e){
			Ti.API.error(e);
		},
		success: function(e){
			Ti.API.info(e);
		}
	});
});

win.add([galleryBtn]);

win.open();
2. After the app launches click open gallery. 3. Select multiple photos from the gallery & click open/select.

Actual result:

1. The app crashes with error:
[ERROR] :  TiExceptionHandler: (main) [4,18345] Failure delivering result ResultInfo{who=null, request=2, result=-1, data=Intent { flg=0x1 clip={image/* U:content://com.android.providers.media.documents/document/image%3A25876 ...} }} to activity {com.app.zzzz/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
[ERROR] :  TiExceptionHandler:
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.media.MediaModule$1.onResult(MediaModule.java:973)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.util.TiActivitySupportHelper$1.onResult(TiActivitySupportHelper.java:60)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.util.TiActivitySupportHelper.onActivityResult(TiActivitySupportHelper.java:117)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.onActivityResult(TiBaseActivity.java:900)
[ERROR] :  TiExceptionHandler:     android.app.Activity.dispatchActivityResult(Activity.java:7759)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.deliverResults(ActivityThread.java:4626)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.handleSendResult(ActivityThread.java:4675)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1950)
[ERROR] :  TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:106)
[ERROR] :  TiExceptionHandler:     android.os.Looper.loop(Looper.java:214)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:7073)
[ERROR] :  TiExceptionHandler:     java.lang.reflect.Method.invoke(Native Method)
[ERROR] :  TiExceptionHandler:     com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
[ERROR] :  TiExceptionHandler:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

Expected result:

1. The app should not crash.

Attachments

FileDateSize
PhotoVideoMultiselectTest.js2020-10-23T21:46:20.000+00003344

Comments

  1. Joshua Quick 2020-10-13

    This is the same issue as [TIMOB-28178], just a different way of reproducing it.
  2. Muhammad Ahmed Fahad 2020-10-22

  3. Muhammad Ahmed Fahad 2020-10-22

    Problem still exists, tested with: SDK: 9.3.0.v20201021081529 Device: Samsung Galaxy Note9 (SM-N9600) Android Version: 10
  4. Joshua Quick 2020-10-23

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12212
  5. Christopher Williams 2020-10-26

    merged to master for 9.3.0 target. Backport PR for 9_2_X required some manual adjustment, but is merged for 9.2.2 target.
  6. Muhammad Ahmed Fahad 2020-10-27

    Thank you very much for the very quick turnaround :) Tested (9.3.0.v20201026143050), Works!
  7. Lokesh Choudhary 2020-10-27

    Verified the fix with SDK 9.3.0.v20201027120230. Closing.

JSON Source