当Image与某些来源一起使用时,React Native签名的APK崩溃在dev

时间:2018-08-25 06:09:11

标签: android react-native

当我在调试模式下运行我的应用程序时 一切正常。

但是当我使用签名的apk时

react-native run-android --variant=release

它将运行正常,直到遇到带有此类源的Image。该应用只会崩溃,只有重启按钮:

<Image source={{uri: "https://upload.wikimedia.org/wikipedia/commons/3/30/Googlelogo.png"}} />

但是使用这样的源将不会有任何错误

<Image source={{uri: "https://facebook.github.io/react-native/docs/assets/favicon.png"}} />

更新:当图像位于FlatList内部时,会发生此错误

UPDATE2:此错误不仅在FlatList中发生。大图片和resizeMode会发生这种情况。如果我设置了调整大小模式,那么我的应用程序将在没有FlatList的单个图像上崩溃,如果我删除resizeMode,则不会出错。

问题在发行版本中发生,我无法正确调试并找到问题。

“ react-native”:“ 0.56.0” “反应”:“ 16.4.1”

更新:问题摘要。 React本机android图像占用大量内存。因此,例如,200kb的图像可能占用20MB的内存。

更新:崩溃报告:

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 3036972 byte allocation with 2619648 free bytes and 2MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java)
at android.graphics.Bitmap.nativeCreate(Bitmap.java)
at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
at android.graphics.Bitmap.createBitmap(Bitmap.java:856)
at android.graphics.Bitmap.createBitmap(Bitmap.java:823)
at com.facebook.imagepipeline.memory.BitmapPool.alloc(BitmapPool.java:51)
at com.facebook.imagepipeline.memory.BitmapPool.alloc(BitmapPool.java:26)
at com.facebook.imagepipeline.memory.BasePool.get(BasePool.java:255)
at com.facebook.imagepipeline.platform.ArtDecoder.decodeStaticImageFromStream(ArtDecoder.java:147)
at com.facebook.imagepipeline.platform.ArtDecoder.decodeJPEGFromEncodedImage(ArtDecoder.java:127)
at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decodeJpeg(DefaultImageDecoder.java:173)
at com.facebook.imagepipeline.decoder.DefaultImageDecoder$1.decode(DefaultImageDecoder.java:56)
at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decode(DefaultImageDecoder.java:119)
at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.doDecode(DecodeProducer.java:254)
at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.access$300(DecodeProducer.java:113)
at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder$1.run(DecodeProducer.java:152)
at com.facebook.imagepipeline.producers.JobScheduler.doJob(JobScheduler.java:202)
at com.facebook.imagepipeline.producers.JobScheduler.access$000(JobScheduler.java:22)
at com.facebook.imagepipeline.producers.JobScheduler$1.run(JobScheduler.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:51)
at java.lang.Thread.run(Thread.java:761)

0 个答案:

没有答案