Crash: width and height must be > 0 (v0.2.1)
See original GitHub issueEvery so often I’ll get this crash from prod in one of my apps:
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:939)
at android.graphics.Bitmap.createBitmap(Bitmap.java:918)
at android.graphics.Bitmap.createBitmap(Bitmap.java:885)
at com.simplify.ink.InkView.clear(InkView.java:377)
at com.simplify.ink.InkView.onSizeChanged(InkView.java:160)
at android.view.View.sizeChange(View.java:16876)
at android.view.View.setFrame(View.java:16849)
at android.view.View.layout(View.java:16764)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
...
The stack trace is pretty straight forward to follow. The exception appears to be occurring during a layout pass. I’m not doing anything crazy - the InkView is defined in an XML layout. It actually has a specified height (199dp) so it’s the width that must be 0 (match parent).
I’m not sure what the circumstances of this are; maybe the activity is being minimised as a layout pass is occuring?
A fix may be to simply wrap bitmap creation with a size check.
edit: While you’re there…
mDebugBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
This line almost doubles the memory footprint of the view; it should probably only be instantiated when debug is enabled.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
android:windowSoftInputMode=“adjustPan” putting this in activity solves the problem
Im facing same problem. Size changes when keyboard opens via clicking edit text