Async loading bug

Async loading bug
0.0 0


Hi all,
I recently stumbled upon this bug. Here’s what i did.

  1. Created 2 apps having same set textures. I used async texture loading to load the textures. (May be having same set of textures wont matter since the problem is with writing to Texture cache)
  2. I launched the first app and waited for the textures to load once the load was complete, i switched to Home Screen.
  3. Next i launched the second app which just stops at the loading screen.

When i traced this, i found that cocos2d-x uses a named semaphore called “ccasync”. Since it is same for both the apps it causes the second app to indefinitely wait. Please look into this,

PS: I was using cocos2d-2.1beta3-x-2.1.0, so i am not sure whether this was resolved in the latest build but i’ll mention it anyway just in case.

Raghu S


You are right there this should not be implemented using a named semaphore. This may even fail if the process crashes, failing to call sem_post() (or somehow leaving the semaphore in an unusable state).

I have not looked at the code yet, but is there any reason why pthread mutexes and condition variables were not used?
I may try out implmenting this over the weekend.


You may wan’t to try this pull request:

This has removed the semaphore with pthread mutex and condition variables.