Skip to content

Android Activity Intents may fail in onActivityResult due to empty data attribute, causing NullPointerException #185

@kobaltcore

Description

@kobaltcore

Logs of this behavior below. For context, this is a file picker that the user backs out of via the 'back' gesture/button. This causes the result to be Activity.CANCELED (which is valid) but the result data is empty (which is expected). Because Ren'Py attempts to log the data to the console in all cases without a null check, this causes a NullPointerException, failing the result delivery and causing Ren'Py code to poll the activity results forever because they can't be delivered.

The offending line is here, it calls resultData.toString() without a null check:

Log.v("python", "onActivityResult(" + requestCode + ", " + resultCode + ", " + resultData.toString() + ")");

12-20 18:46:18.330  1731  1731 E TransactionExecutor: Failed to execute the transaction: tId:-723009752 ClientTransaction{
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752   transactionItems=[
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752     TopResumedActivityChangeItem{mActivityToken=android.os.BinderProxy@772a63b,onTop=true}
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752     Target activity: org.renpy.android.PythonSDLActivity
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752     ActivityResultItem{mActivityToken=android.os.BinderProxy@772a63b,resultInfoList=[ResultInfo{who=null, request=1, result=0, data=null}]}
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752     Target activity: org.renpy.android.PythonSDLActivity
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752     ResumeActivityItem{mActivityToken=android.os.BinderProxy@772a63b,procState=2,isForward=false,shouldSendCompatFakeFocus=false}
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752     Target activity: org.renpy.android.PythonSDLActivity
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752   ]
12-20 18:46:18.330  1731  1731 E TransactionExecutor: tId:-723009752 }
12-20 18:46:18.330  1731  1731 D AndroidRuntime: Shutting down VM
12-20 18:46:18.331  1731  1731 E AndroidRuntime: FATAL EXCEPTION: SDLActivity
12-20 18:46:18.331  1731  1731 E AndroidRuntime: Process: MYGAME, PID: 1731
12-20 18:46:18.331  1731  1731 E AndroidRuntime: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=null} to activity {MYGAME/org.renpy.android.PythonSDLActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.toString()' on a null object reference
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.ActivityThread.deliverResults(ActivityThread.java:7016)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.ActivityThread.handleSendResult(ActivityThread.java:7055)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:78)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:63)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:3309)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:114)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.os.Looper.loopOnce(Looper.java:266)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:361)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:10320)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:675)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1002)
12-20 18:46:18.331  1731  1731 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.toString()' on a null object reference
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at org.renpy.android.PythonSDLActivity.onActivityResult(PythonSDLActivity.java:636)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.Activity.onActivityResult(Activity.java:7980)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.Activity.internalDispatchActivityResult(Activity.java:10109)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.Activity.dispatchActivityResult(Activity.java:10086)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        at android.app.ActivityThread.deliverResults(ActivityThread.java:7005)
12-20 18:46:18.331  1731  1731 E AndroidRuntime:        ... 14 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions