Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28178] Android: Canceling out of Ti.Media.openPhotoGallery() causes a crash as of 9.1.0

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-11-23T23:28:22.000+0000
Affected Version/sRelease 9.1.0
Fix Version/sRelease 9.3.0
ComponentsAndroid
Labelsandroid, camera, crash, media, photogallery, regression
ReporterAndrea Vitale
AssigneeJoshua Quick
Created2020-10-07T16:01:58.000+0000
Updated2020-11-23T23:28:22.000+0000

Description

*Summary:* As of Titanium 9.1.0, calling Ti.Media.openPhotoGallery() and then backing-out of the gallery apps without making a selection will cause a crash on Android. This issue does not happen if you select a photo. It only happens when you cancel out. *Steps to reproduce:*

Build and run [^PhotoVideoSelectTest.js] on Android with Titanium 9.1.0 or higher.

When the alert dialog appears, select "Photo".

Back out of the photo gallery app. _(Do NOT select a photo.)_

Notice the app crashes.

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=null} to activity {com.comehome/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.net.Uri android.content.Intent.getData()' on a null object reference
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4496)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4538)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6863)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.net.Uri android.content.Intent.getData()' on a null object reference
        at ti.modules.titanium.media.MediaModule$1.onResult(MediaModule.java:970)
        at org.appcelerator.titanium.util.TiActivitySupportHelper$1.onResult(TiActivitySupportHelper.java:60)
        at org.appcelerator.titanium.util.TiActivitySupportHelper.onActivityResult(TiActivitySupportHelper.java:117)
        at org.appcelerator.titanium.TiBaseActivity.onActivityResult(TiBaseActivity.java:900)
        at android.app.Activity.dispatchActivityResult(Activity.java:7476)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4489)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4538)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6863)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
*Note:* [~Andrea.Vitale] has an end-user that has this issue on a OnePlus A3003. The end-user claims that an image is being selected, although this crash should only happen if you cancel out of the gallery. Either way, the line of code that it's crashing on indicates no selection was made.

Attachments

FileDateSize
PhotoVideoSelectTest.js2020-10-08T00:20:09.000+00001707
Ti Error.mov2020-10-07T16:00:55.000+00001107025

Comments

  1. Joshua Quick 2020-10-08

    [~Andrea.Vitale], you've actually found a regression that was introduced in Titanium 9.1.0. The crash will happen when you cancel/back-out of the photo gallery instead of selecting an image. The device model you use doesn't matter.
  2. Joshua Quick 2020-10-08

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12165
  3. Satyam Sekhri 2020-10-08

    FR Passed
  4. Muhammad Ahmed Fahad 2020-10-22

  5. Muhammad Ahmed Fahad 2020-10-23

    please assign a high Priority for this as it has been broken for a while now..
  6. Joshua Quick 2020-10-23

    [~fahad86], we're going to re-open [TIMOB-28193] and resolve the multiselect issue via that ticket. Thanks.
  7. Hans Knöchel 2020-10-30

    How did this not make it into 9.2.2.GA? :-( So this needs to be cherry picked manually again.
  8. Satyam Sekhri 2020-11-23

    Verified on: Mac OS: 10.15.4 SDK: 9.3.0.v20201123121926 Appc CLI: 8.1.1 JDK: 11.0.6 Node: 12.16.1 Studio: 6.0.0.202005141803 Device: Pixel 3 XL(v11.0) emulator

JSON Source