-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException: 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference #1002
Comments
can you provide a sample app? |
You should be able to replicate the problem by enabling the "Don't keep activities" option in Android Developer Options (Developer options => Apps => Don't keep activities (Destroy every activity as soon as the user leaves it.)) |
When doing that on the android simulator, I run into a different crash stacktrace
Maybe this depends on the API level of the device and/or the installed chrome version though. It kinda seems related. |
Created a sample app: https://github.com/secondVISION/cordova-android-crash How to reproduce:
Crash log:
|
…on a destroyed activity
…m running on a destroyed activity
…on a destroyed activity
…m running on a destroyed activity
) * (android) #1002: Add Null Pointer Checks to prevent Cordova from running on a destroyed activity * (android) Add logging statements if Cordova Activity does not exist anymore (i.e. is destroyed) Co-authored-by: Habets Rick <rick.habets@kbc.be>
…ache#1148) * (android) apache#1002: Add Null Pointer Checks to prevent Cordova from running on a destroyed activity * (android) Add logging statements if Cordova Activity does not exist anymore (i.e. is destroyed) Co-authored-by: Habets Rick <rick.habets@kbc.be>
Bug Report
Problem
What is expected to happen?
Cordova should silently exit.
What does actually happen?
Cordova crashes because the parent Activity is not alive anymore
Information
Start a CordovaWebview and load a slow/large website.
cordovaWebView.loadUrl(url)
If you return to the previous activity (by using the (hardware) back button), cordova will try to execute
cordova.getActivity().runOnUiThread()
, but the activity is no longer there.e.g., https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaWebViewImpl.java#L187
Stacktrace:
Command or Code
See information above on how to reproduce.
Environment, Platform, Device
Android / All devices / All OS
Version information
Android Studio
Cordova 8.1.0
Checklist
Found issue: Application crash in CordovaWebViewImpl.java runOnUiThread #884 but this was closed due to lack of information
Crash occured on
'org.apache.cordova:cordova:6.2.3'
Updated to (crashed as well):
'org.apache.cordova:framework:8.1.0'
The text was updated successfully, but these errors were encountered: