airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
206 stars 11 forks source link

Text inputs generate stack traces #3000

Open CT-PDept opened 10 months ago

CT-PDept commented 10 months ago

Problem Description

Users are unable to click into a text input. Hooking the app up to Android Studio to check the logs I have observed several stack traces related to text input fields.

java.lang.NullPointerException: Attempt to invoke virtual method 'int com.adobe.air.AndroidStageTextAsync.getMaxChars()' on a null object reference at com.adobe.air.AndroidStageText.getMaxChars(AndroidStageText.java:403) at com.adobe.air.customHandler.callTimeoutFunction(Native Method) at com.adobe.air.customHandler.handleMessage(customHandler.java:34) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.adobe.air.AndroidStageTextAsync.getRestrict()' on a null object reference at com.adobe.air.AndroidStageText.getRestrict(AndroidStageText.java:376) at com.adobe.air.customHandler.callTimeoutFunction(Native Method) at com.adobe.air.customHandler.handleMessage(customHandler.java:34) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap com.adobe.air.AndroidStageTextAsync.captureSnapshot(int, int)' on a null object reference at com.adobe.air.AndroidStageText.captureSnapshot(AndroidStageText.java:571) at com.adobe.air.customHandler.callTimeoutFunction(Native Method) at com.adobe.air.customHandler.handleMessage(customHandler.java:34) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

I assume all Android. I have tried and successfully replicated on:

Android Physical: Galaxy S9 Android 10 Galaxy S10+ Android 12

Emulator: Pixel XL Android 13

Steps to Reproduce

Open the app from scratch.

If you go straight to the page and straight to the input it works as expected.
Once you click on another page and return, or if you went to some other pages first, stack traces are logged to Logcat when you enter the page and you are unable to click into the input field.

Give us a minimal example:

<s:TextInput id="searchBar" width="100%" height="100%" styleName="searchInput" change="searchBar_changeHandler(event)" prompt="{IconText.search}"/>

There appear to be several other issues logged relating to Null Pointer exceptions, but none with the exact functions I am seeing in the logs.

ajwfrost commented 10 months ago

Just to confirm that this is what I think it is ... are you able to confirm if you have the runtimeInBackgroundThread setting in your application descriptor XML file, set to true? And these errors would presumably go away if this was set to false?

We've added some protection already for some functions but maybe not all, I'll review these to ensure we're not getting caught out (the issue happens due to the async nature of these calls now, because we are running AIR in a background thread but a lot of these UI updates have to then be in the main thread, and there's not sufficient coordination or thread-safety between these)

thanks

CT-PDept commented 10 months ago

We did not have runtimeInBackgroundThread explicitly set. Trying both false and true does not change the functionality we are seeing.

ajwfrost commented 9 months ago

Okay thanks -> belatedly investigating and finding that the changes we made in also to support the asynchronous runtime on Android, also means it's impossible to take a StageText element off the stage and then add it back later on. The same root cause as this -> we lose a reference to the underlying 'AndroidStageText' class when it's removed from the stage...

Will get this into our next release!

thanks