Monday, September 19, 2011

[android-developers] InputMethod crashing with NullPointerException

Hi,

Currently I'm encountering a weird issue in which my IME process is
getting crashed even though its not the default IME. The following
thread which was posted earlier nearly talks about the same issue.

http://groups.google.com/group/android-developers/browse_thread/thread/43e45a7c2e4d067f

I'm assuming that its not the issue with my IME alone as the above
thread speaks about Latin IME. Following are the steps to reproduce
the issue:

1) After installing your IME, make it the default one such that your
SIP appears on the editor( say for example GMail ) application. close
this editor and open another editor.

2) After typing some words, keep the cursor in between a word and long
press on the editor to bring up the options with "Add word to
dictionary". Select that option, which will open the Add word editor
separately.

3) There again type (or) add some words from candidate bar and then
switch the IME from yours to "Android default" IME. After the
switching is done, tap on the "back" key twice.

4) On the second tapping of back key, the "Null Pointer Exception"
crash appears on the screen with my IME's process mentioned(not the
Android default one).

Here is the exact piece of crash log which I took out the device( I'm
actually using a tablet which is running on 2.3.3 ).

09-15 14:23:11.720: WARN/InputManagerService(113): Window already
focused, ignoring focus gain of:
com.android.internal.view.IInputMethodClient$Stub$Proxy@40864a00
09-15 14:23:17.190: DEBUG/AndroidRuntime(24837): Shutting down VM
09-15 14:23:17.190: WARN/dalvikvm(24837): threadid=1: thread exiting
with uncaught exception (group=0x40150560)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): FATAL EXCEPTION: main
09-15 14:23:17.190: ERROR/AndroidRuntime(24837):
java.lang.NullPointerException
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
android.inputmethodservice.IInputMethodSessionWrapper.executeMessage(IInputMethodSessionWrapper.java:
88)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
com.android.internal.os.HandlerCaller
$MyHandler.handleMessage(HandlerCaller.java:61)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
android.os.Looper.loop(Looper.java:123)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
android.app.ActivityThread.main(ActivityThread.java:3683)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
java.lang.reflect.Method.invokeNative(Native Method)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
java.lang.reflect.Method.invoke(Method.java:507)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-15 14:23:17.190: ERROR/AndroidRuntime(24837): at
dalvik.system.NativeStart.main(Native Method)

I browsed the net and found from sources that the
InputMethodSessionWrapper in its handler is still trying to use the
old(invalid) InputMethodSession and calls UpdateExtractedText() with
out a "null" check. My question is after the IME is swicthed from mine
to Android default one, why the InputMethodSessionWrapper is still
trying to use the old inputmethodsession object ?
Am I missing something from my onDestroy() call which is causing this
issue ?(I double checked and found that all required resources like
registered receivers are unregistered & things like that. Moreover if
I swap the positions of IMEs and follow above same steps, Android
default IME is not crashing) (or) am I missing any vital interface
methods from being overridden in my IME?( I even tried keeping dummy
implementation of onbindInput() and onUnbindInput() and called the
super class method, without success in this regard) (or) is this a
issue which needs to be addressed from the platform end ?

Thanks,

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment