agwells / dotdash-keyboard-android

The world's most popular open source Morse code keyboard for Android! (probably)
GNU General Public License v3.0
32 stars 5 forks source link

Crashes on startup in 2.1 and earlier #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Any version after release-006 crashes on startup in 2.1, 1.6, and 1.5. The 
particular change that caused it is 0661d92ecf9dcaf83c940ebbf5a8e93b7c13a439, 
when I started calling KeyboardView.invalidateKey() during 
InputMethodService.onStartInputView(). Here's the stack trace:

04-21 18:05:38.179: E/AndroidRuntime(545): Uncaught handler: thread main 
exiting due to uncaught exception
04-21 18:05:38.189: E/AndroidRuntime(545): java.lang.IllegalArgumentException: 
width and height must be > 0
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.graphics.Bitmap.nativeCreate(Native Method)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.graphics.Bitmap.createBitmap(Bitmap.java:468)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.inputmethodservice.KeyboardView.onBufferDraw(KeyboardView.java:575)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.inputmethodservice.KeyboardView.invalidateKey(KeyboardView.java:906)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
net.iowaline.dotdash.DotDashIMEService.onWindowShown(DotDashIMEService.java:408)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.inputmethodservice.InputMethodService.showWindowInner(InputMethodService
.java:1334)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java
:1278)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(Inpu
tMethodService.java:388)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrappe
r.java:148)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java
:45)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.os.Handler.dispatchMessage(Handler.java:99)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.os.Looper.loop(Looper.java:123)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
android.app.ActivityThread.main(ActivityThread.java:4203)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
java.lang.reflect.Method.invokeNative(Native Method)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
java.lang.reflect.Method.invoke(Method.java:521)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
04-21 18:05:38.189: E/AndroidRuntime(545):  at 
dalvik.system.NativeStart.main(Native Method)

I tried wrapping some code around the call to invalidateKey() which makes sure 
that the key exists and has a non-zero width and height, but it still happened.

I'm not sure what the proper solution is. I need to clear the state of these 
buttons whenever the view is restarted, and onStartInputView() is the hook for 
that. Possibly I could put the parts where it clears the key states in 
onFinishInputView() instead.

Original issue reported on code.google.com by aaronwells on 21 Apr 2012 at 6:15

GoogleCodeExporter commented 9 years ago

Original comment by aaronwells on 21 Apr 2012 at 6:15

GoogleCodeExporter commented 9 years ago
Google Play showed only a handful of pre-2.2 users, so I simply dropped support 
for those versions because it became apparent it would require a large amount 
of effort for me to fix this problem, and my development time is limited, and I 
can't have an app up which crashes when you try to use it.

If you are a pre-2.2 user and an Android developer, well, I've listed the 
problem git commit above. You could check out the commit immediately before 
that, build it, and run that. What that commit does, is blank out the space bar 
each time the keyboard pops up. Without it, if you had typed ".-" but not hit 
space, then close the keyboard, then re-open it, you'll see the space bar shows 
".-", but if you hit space or any other key it'll be as if the space bar were 
blank. Which, in reality, it is.

Maybe the best compatibility solution is to detect the OS version, and if it's 
pre-2.2, disable the functionality that clears the space bar each time you 
close the Keyboard. Which is to say, since I can't make the keyboard stop 
showing that ".-", make it so that the ".-" is still actually loaded in there. 
Yeah, that's probably the least glitchy-looking way to resolve this.

Original comment by aaronwells on 3 Sep 2012 at 12:05

GoogleCodeExporter commented 9 years ago
1. It appears that I did not correctly change the Android versions this app can 
be downloaded for. It still shows up for Market users with 1.6 or 2.1. Oops! 
They'll download it, and then it'll start crashing inmediatamente. Oops!

2. But I've fixed it! In the end I couldn't figure out how to avoid the 
exception, but I figured the functionality wasn't completely essential. So, I 
just wrapped the call in a try/catch block, and ignore the exception if it 
occurs.

So for look for a fix in the next release.

Original comment by aaronwells on 14 Sep 2012 at 10:48