Too many files error on Nexus 5/6 Lollipop
I am currently working on a game project using cocos2dx-2.2.2.
When I perform some operation (read textures from a file and show a dialog), the application may force close or the screen will freeze (the network stream is still running).
This happens sometimes when connected, but rarely happens on other devices.
the log looks like this:
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): : failed to queueBuffer
12-29 15:23:01.169: W/Adreno-EGL(2128): : 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)
Any ideas what might go wrong?
source to share
This looks very similar to the error I was getting. Mine was not communication specific (although I fixed it working with the Nexus 9). Are you closing the FD you open correctly? This was my problem.
In my specific scenario: 1) I opened audio files for OpenSL with:
AAssetManager_open
2) obtaining FD with
AAsset_openFileDescriptor
3) calling AAsset_close
on AAsset and using FD.
The problem is that there is no corresponding AAsset_closeFileDescriptor file or mention of closing FD. I thought it was weird when I originally wrote the code, but assumed it was handled by later methods. However, my gut was right and everything she did was opening up more and more FDs for audio files as I played them, but never released them until the inner limit was reached.
The fix I'm using is to call:
close(fd);
When I finished with FD. You can find in
#include <fcntl.h>
source to share