【问题标题】:"Too Many Files" Error On Nexus 5/6 LollipopNexus 5/6 Lollipop 上的“文件太多”错误
【发布时间】:2014-12-29 07:59:00
【问题描述】:

我目前正在使用 cocos2dx-2.2.2 开发一个游戏项目。

当我做一些操作(从文件中读取纹理并显示一个对话框)时,应用程序可能会强制关闭或屏幕将冻结(但网络线程仍在运行)。

偶尔会发生在 nexus 上,但很少发生在其他设备上。

日志如下:

12-29 15:23:01.169: E/Surface(2128): queueBuffer: error queuing buffer to SurfaceTexture, -22
12-29 15:23:01.169: W/Adreno-EGLSUB(2128): <SwapBuffers:1340>: failed to queueBuffer
12-29 15:23:01.169: W/Adreno-EGL(2128): <qeglDrvAPI_eglSwapBuffers:3809>: EGL_BAD_SURFACE
12-29 15:23:01.204: E/Parcel(2128): Parcel::writeDupFileDescriptor failed:
12-29 15:23:01.204: E/Parcel(2128):   fd=1002 flags=0 err=0(Success)
12-29 15:23:01.204: E/Parcel(2128):   dupFd=-1 dupErr=24(Too many open files) flags=-1 err=9(Bad file number)
12-29 15:23:01.204: E/Parcel(175): dup failed in Parcel::read, fd 0 of 1
12-29 15:23:01.204: E/Parcel(175):   dup(-2147483647) = -1 [errno: 9 (Bad file number)]
12-29 15:23:01.204: E/Parcel(175):   fcntl(-2147483647, F_GETFD) = -1 [errno: 9 (Bad file number)]
12-29 15:23:01.204: E/Parcel(175):   flat 0x0 type 0
12-29 15:23:01.216: D/Parcel(175): #00 pc 0000cff1  /system/lib/libutils.so (android::CallStack::update(int, int)+52)
12-29 15:23:01.216: D/Parcel(175): #01 pc 0000d107  /system/lib/libutils.so (android::CallStack::CallStack(char const*, int)+38)
12-29 15:23:01.216: D/Parcel(175): #02 pc 00023513  /system/lib/libbinder.so (android::Parcel::read(android::Parcel::FlattenableHelperInterface&) const+246)
12-29 15:23:01.216: D/Parcel(175): #03 pc 00033035  /system/lib/libgui.so (android::BnGraphicBufferProducer::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+568)
12-29 15:23:01.216: D/Parcel(175): #04 pc 0001a6d9  /system/lib/libbinder.so (android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+60)
12-29 15:23:01.216: D/Parcel(175): #05 pc 0001f787  /system/lib/libbinder.so (android::IPCThreadState::executeCommand(int)+582)
12-29 15:23:01.216: D/Parcel(175): #06 pc 0001f8ab  /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+38)
12-29 15:23:01.216: D/Parcel(175): #07 pc 0001f8ed  /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+48)
12-29 15:23:01.216: D/Parcel(175): #08 pc 00023a5b  /system/lib/libbinder.so
12-29 15:23:01.216: D/Parcel(175): #09 pc 000104d5  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+112)
12-29 15:23:01.216: D/Parcel(175): #10 pc 00010045  /system/lib/libutils.so
12-29 15:23:01.216: D/Parcel(175): #11 pc 000162e3  /system/lib/libc.so (__pthread_start(void*)+30)
12-29 15:23:01.216: D/Parcel(175): #12 pc 000142d3  /system/lib/libc.so (__start_thread+6)

有什么想法可能出错吗?

【问题讨论】:

  • 您好,您对这个问题有什么想法吗?有什么解决办法吗?

标签: android c++ cocos2d-x


【解决方案1】:

这看起来与我遇到的错误非常相似。我的不是特定于 nexus(尽管我在 Nexus 9 上修复了它)。您是否正确关闭了您正在打开的 FD?那是我的问题。

在我的具体情况下: 1) 我正在为 OpenSL 打开音频文件:

AAssetManager_open

2) 使用

获取 FD
AAsset_openFileDescriptor

3) 在 AAsset 上调用 AAsset_close,并使用 FD。

问题是没有对应的AAsset_closeFileDescriptor,也没有提到关闭FD。我最初编写代码时认为这很奇怪,但假设这是由后来的方法处理的。然而我的直觉是正确的,它所做的只是在我播放音频文件时打开越来越多的 FD,但在达到内部限制之前永远不会释放它们。

我使用的修复方法是调用:

close(fd);

当我完成 FD 时。您可以在

中找到关闭
#include <fcntl.h>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 2019-02-23
    • 2016-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多