Hi All,
Please find the test code below:
websiteView1 = native.newWebView( display.contentWidth \* 0.5, display.contentHeight \* 0.5 , display.contentWidth - 20, display.contentHeight - 20 ) websiteView1:request( "http://google.com")
Compile code, works in simulator. Generate APK, load into device.
Step 1: open app, it will open webview with google page inside it
Step 2: hit back button -> App crash happens.
I also managed to grab a trace, and it had the following:
java.lang.NullPointerException at com.ansca.corona.CoronaWebView.destroy(CoronaWebView.java:136) at com.ansca.corona.ViewManager$14.run(ViewManager.java:633) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)
Workaround: I am using the following workaround to prevent an app crash -
websiteView1 = native.newWebView( display.contentWidth \* 0.5, display.contentHeight \* 0.5 , display.contentWidth - 20, display.contentHeight - 20 ) websiteView1:request( "http://google.com") -- detect an app suspend event and close webview to prevent crash local function onSystemEvent( event ) if ( event.type == "applicationSuspend" ) then websiteView1:removeSelf() websiteView1 = nil end end Runtime:addEventListener( "system", onSystemEvent )
This was not happening until Daily Build 2210 (I think), and then I jumped to Build 2223 directly and this has popped up. I am not too sure though if this existed in 2100 but nevertheless it seems like a bug?
Hope the workaround helps other developers.
Cheers,
Anshuman