简体   繁体   English

Android 4.4 Kitkat上的Aquery Android问题

[英]Aquery Android Issue on Android 4.4 Kitkat

I a getting an issue due to Aquery library for lazy loading of images on Android 4.4 Kitkat only when scrolling through the GridView/ListView loading images with pagination. 我只是在滚动浏览带有分页的GridView / ListView加载图像时,由于Aquery库在Android 4.4 Kitkat上延迟加载图像而出现问题。

Following are the logs: 以下是日志:

12-03 10:39:43.678: W/AQuery(6261): reporting:java.io.IOException: open failed: EMFILE (Too many open files)
12-03 10:39:43.678: W/AQuery(6261): at java.io.File.createNewFile(File.java:946)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.getPreFile(AbstractAjaxCallback.java:1150)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.httpDo(AbstractAjaxCallback.java:1609)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.httpGet(AbstractAjaxCallback.java:1344)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.network(AbstractAjaxCallback.java:1243)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.networkWork(AbstractAjaxCallback.java:1082)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.backgroundWork(AbstractAjaxCallback.java:1014)
12-03 10:39:43.678: W/AQuery(6261): at com.androidquery.callback.AbstractAjaxCallback.run(AbstractAjaxCallback.java:977)
12-03 10:39:43.678: W/AQuery(6261): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
12-03 10:39:43.678: W/AQuery(6261): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
12-03 10:39:43.678: W/AQuery(6261): at java.lang.Thread.run(Thread.java:841)
12-03 10:39:43.678: W/AQuery(6261): Caused by: libcore.io.ErrnoException: open failed: EMFILE (Too many open files)
12-03 10:39:43.678: W/AQuery(6261): at libcore.io.Posix.open(Native Method)
12-03 10:39:43.678: W/AQuery(6261): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
12-03 10:39:43.678: W/AQuery(6261): at java.io.File.createNewFile(File.java:939)
12-03 10:39:43.678: W/AQuery(6261): ... 10 more

It seems I need to Minimize Open Files on External Storage but how to do it? 我似乎需要最小化外部存储上的打开文件但是如何做到这一点? Any idea ??? 任何想法 ???

Android Query发布了另一个版本(0.26.8)来解决此问题: https//code.google.com/p/android-query/wiki/ReleaseNote#0.26.8

Edit: I can reproduce it, and it seems to happen on Kitkat only. 编辑:我可以重现它,它似乎只发生在Kitkat上。 Previously versions of aquery also have this issue. 之前版本的aquery也有这个问题。 Checking what's going on now. 检查现在发生了什么。

Ok I just tested it. 好的,我刚刚测试过它。 The issue is cause my inPurgeable settings: 问题是导致我的inPurgeable设置:

Why would I ever NOT use BitmapFactory's inPurgeable option? 为什么我不使用BitmapFactory的inPurgeable选项?

It will happen when there are too many images displayed. 当显示的图像太多时会发生这种情况。 Without the option, app will run out of memory quicker than the file limit (so it's even worse). 如果没有该选项,应用程序将比文件限制更快地耗尽内存(因此情况会更糟)。

What I suggest is limit the number of images in Activity or Fragments that is still in use. 我建议限制仍在使用的活动或碎片中的图像数量。

I am checking if there's a better solution, but will likely take some time. 我正在检查是否有更好的解决方案,但可能需要一些时间。

You might also try other image loading library and see if that happens. 您也可以尝试其他图像加载库,看看是否会发生这种情况。

I met the same problem in KitKat. 我在KitKat遇到了同样的问题。 Fix is following: change options.inInputShareable from 'true' to 'false' in BitmapAjaxCallback.java Every bitmap loaded from any URL is stored to file. 修复如下:在BitmapAjaxCallback.java中将options.inInputShareable从'true'更改为'false'从任何URL加载的每个位图都存储到文件中。 And if inInputShareable is true, your process has duplicated file descriptor for sharing. 如果inInputShareable为true,则您的进程具有重复的文件描述符以进行共享。 So when >1024 file descriptors are leaked, EMFILE is occured. 因此,当泄漏> 1024个文件描述符时,会发生EMFILE。 But actually I can't understand why it worked correctly before KitKat :) 但实际上我无法理解为什么它在KitKat之前正常工作:)

PS inInputShareable=false works as inPurgeable=false and leads to rapid OOM :( Correct fix in AQuery is change call of BitmapFactory.decodeFileDescriptor to BitmapFactory.decodeByteArray (Don't use decodeStream!!! It ignores inPurgeable despite its JavaDocs) PS inInputShareable = false作为inPurgeable = false并导致快速OOM :( AQuery中的正确修复是将BitmapFactory.decodeFileDescriptor更改为BitmapFactory.decodeByteArray (不要使用decodeStream !!!它忽略了inPurgeable,尽管它的JavaDocs)

And I've found that the issue is related with bug in KitKat: https://code.google.com/p/android/issues/detail?id=65638 我发现这个问题与KitKat中的错误有关: https//code.google.com/p/android/issues/detail? id = 65638

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM