kuhrusty / MorbadScorepad

DUNGEON DEGENERATES support app.
GNU General Public License v3.0
7 stars 0 forks source link

DangerDeckActivity crashes on Samsung S6 #16

Closed kuhrusty closed 5 years ago

kuhrusty commented 5 years ago

vaderizer reports that the Danger deck activity crashes on one of his devices (Samsung S6 Active phone running Android 7.0). I am able to reproduce this both in Samsung Remote Test Lab and on my box in a virtual device:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.kuhrusty.morbadscorepad, PID: 6509
    java.lang.RuntimeException: Canvas: trying to draw too large(157286400bytes) bitmap.
        at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)
        at android.graphics.Canvas.drawBitmap(Canvas.java:1415)
        at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
        at android.widget.ImageView.onDraw(ImageView.java:1286)
        ...

app/src/main/res/drawable/dangerbg.jpg is 1280x1920, but that's less than the size of the S6's screen; 157286400 bytes / (1280 1920) = 64, or 4 4 * 4; I suspect what's happening (at least on that device) is, the image is being treated as mdpi, and is being scaled up 4x to xxxhdpi, so the first thing to try is moving dangerbg.jpg into drawable-xxxhdpi.

kuhrusty commented 5 years ago

Oh yeah, see more blather about drawables in CONTRIBUTING.md.

kuhrusty commented 5 years ago

Moving the images from drawable to drawable-nodpi seemed to fix the problem.

sgbeal commented 5 years ago

It's magic.

kuhrusty commented 5 years ago

It's magic.

Yeah, I was thinking I was going to need one layout using the high-resolution image for high-resolution screens, and one layout using the high-resolution image for large, low-resolution screens, but in looking up how to define large screens, I came across the nodpi business. (I would've been mad if I'd needed multiple layout XML files whose only difference was, "you're telling me the screen has a lot of pixels, so I'm telling you to use the image with a lot of pixels"; they have computers for stuff like that.)