[
https://issues.apache.org/jira/browse/CB-2458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13580856#comment-13580856
]
mike billau commented on CB-2458:
---------------------------------
Okay, so I made some progress and submitted a pull request:
https://github.com/apache/cordova-android/pull/15
It turns out that handleDestory() was causing an NPE both when we call finish()
(scenario 1) and when Android natively tries to close the app (scenario 2.) The
problem was that the tear down code in handleDestory() was using loadUrl() to
fire exit events for Javascript, but it uses a baseUrl variable that never gets
initialized. baseUrl get populated in loadUrlIntoView(), so I just call that
method first in the handleDestory() and it seems to work fine. Now with the
pull request I can't reproduce either scenario like before. Can sombody please
have a look at the pull request and give some feedback? Thanks.
> Clicking back button while app is loading causes a NPE
> ------------------------------------------------------
>
> Key: CB-2458
> URL: https://issues.apache.org/jira/browse/CB-2458
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Affects Versions: 2.3.0, 2.4.0
> Reporter: Simon MacDonald
> Assignee: Simon MacDonald
> Fix For: 2.5.0
>
>
> Basically the problem is that they have a situation where the user will hit
> the "back" button before loadURL() has been called, causing an NPE and a bad
> exit.
> 02-18 09:49:35.681: E/AndroidRuntime(18993): FATAL EXCEPTION: main
> 02-18 09:49:35.681: E/AndroidRuntime(18993): java.lang.NullPointerException
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> org.apache.cordova.CordovaWebView.startOfHistory(CordovaWebView.java:912)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> org.apache.cordova.CordovaWebView.onKeyDown(CordovaWebView.java:719)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.KeyEvent.dispatch(KeyEvent.java:2609)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.View.dispatchKeyEvent(View.java:7198)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1354)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.webkit.WebView.access$701(WebView.java:262)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.webkit.WebView$PrivateAccess.super_dispatchKeyEvent(WebView.java:1786)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.webkit.WebViewClassic.dispatchKeyEvent(WebViewClassic.java:5716)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.webkit.WebView.dispatchKeyEvent(WebView.java:2110)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1359)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1920)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1395)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.app.Activity.dispatchKeyEvent(Activity.java:2370)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1847)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3701)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3651)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2818)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.os.Looper.loop(Looper.java:137)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> android.app.ActivityThread.main(ActivityThread.java:5039)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> java.lang.reflect.Method.invokeNative(Native Method)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> java.lang.reflect.Method.invoke(Method.java:511)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
> 02-18 09:49:35.681: E/AndroidRuntime(18993): at
> dalvik.system.NativeStart.main(Native Method)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira