You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/09/27 10:00:21 UTC

[GitHub] [cordova-plugin-splashscreen] baffalop opened a new issue #232: Fatal `OutOfMemoryError` error when splashscreen image too large

baffalop opened a new issue #232: Fatal `OutOfMemoryError` error when splashscreen image too large
URL: https://github.com/apache/cordova-plugin-splashscreen/issues/232
 
 
   # Bug Report
   
   ## Problem
   
   The documentation does not explicitly talk about the sizes required for Android splashscreens. After the fact, I noticed that the Example Configuration includes the four sizes for landscape and portrait, but before that I was under the impression that the `SplashMaintainAspectRatio` would be sufficient to resize/crop my base image, which was sized to maximum iPad requirements.
   
   ### What is expected to happen?
   
   Source image of any size will be scaled and cropped to device dimensions similarly to `background-size: cover`.
   
   At the very least, if the below is an Android limitation, the documentation should warn to be careful about source image sizes.
   
   ### What does actually happen?
   
   The app crashes on launch, with the dialogue "[app] has stopped"/"[app] keeps stopping". This only happens for certain Android devices, but it seemed to be a majority of them.
   
   Logcat shows `Throwing OutOfMemoryError "Failed to allocate a 268697676 byte allocation with 4194304 free bytes and 186MB until OOM"` which can be traced back to splashscreen image rendering. The fact that it's allocating >250MB for a 794KB image seems like an implementation flaw.
   
   ## Information
   
   Logcat shows the following trace:
   
   ```
   09-21 08:42:40.209 25531 25531 W art     : Throwing OutOfMemoryError "Failed to allocate a 268697676 byte allocation with 4194304 free bytes and 186MB until OOM"
   09-21 08:42:40.219 25531 25531 D skia    : --- allocation failed for scaled bitmap
   09-21 08:42:40.224 25531 25531 D AndroidRuntime: Shutting down VM
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: FATAL EXCEPTION: main
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: Process: com.my.app, PID: 25531
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 268697676 byte allocation with 4194304 free bytes and 186MB until OOM
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1155)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:720)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.content.res.Resources.getDrawable(Resources.java:771)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.content.Context.getDrawable(Context.java:525)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.widget.ImageView.resolveUri(ImageView.java:864)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.widget.ImageView.setImageResource(ImageView.java:448)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.splashscreen.SplashScreen$5.run(SplashScreen.java:296)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.app.Activity.runOnUiThread(Activity.java:5910)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.splashscreen.SplashScreen.showSplashScreen(SplashScreen.java:288)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.splashscreen.SplashScreen.pluginInitialize(SplashScreen.java:113)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:58)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:97)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.PluginManager.init(PluginManager.java:86)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:117)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:149)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:224)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at com.my.app.MainActivity.onCreate(MainActivity.java:39)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:6723)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.app.ActivityThread.-wrap12(ActivityThread.java)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:102)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:154)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6128)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
   09-21 08:42:40.241 25531 25531 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
   ```
   
   ### Command or Code
   
   App launch
   
   ### Environment, Platform, Device
   
   The majority Android devices. I couldn't find a pattern, since some of the devices on which the app successfully loaded were very low spec and some new flagship devices failed to load, but some succeeded.
   
   ### Version information
   
   Cordova CLI: 9.0.0 (cordova-lib@9.0.1)
   cordova-plugin-splashscreen: 5.0.3
   Android API 28
   JDK: adoptopenjdk-8
   
   ## Checklist
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org