Problem loading CCSpriteSheet on worker thread in Android

RobEplerRobEpler USMember

I'm showing an animation on the main thread while I load character sprite sheets in the background on a worker thread. The code below works fine on iOS, but on Android the thread never returns and never throws an exception:

            await Task.Run(() => {
                var theSpriteSheet = new CCSpriteSheet ("spritesheet.plist", "spritesheet.png");
            });

I can load it on the main thread just fine.
Any ideas, folks? This is something which has to work.

Posts

  • I ran exactly into the same issue and could not solve it, the idea was to draw some stuff in the background and load on the screen later. I would just get the Exception "EGL_BAD_ACCESS".

  • RobEplerRobEpler USMember

    Thanks, Kai. I think I saw your post about it before actually. It's also worth noting that this used to work on previous releases of CocosSharp! The code snippet above is just an example, obviously, it is not super useful code exactly as is shown but you get the idea.

    I tried a dozen variations, the only things that really work for me so far are done from the main thread and that causes animations to freeze while it's loading sprite sheets - not helpful when you want to do an animated "Loading" message.

    If I make any progress I'll let you know, really hoping to hear from one of the experts on this though.

  • RobEplerRobEpler USMember

    Okay - update: I reinstalled some xamarin android player devices and also tried it on real android hardware.

    The code does execute (yay!) but it does block the main thread, which means any running animations freeze. That sucks! and I think it does it on iOS too.

    Do we have to go back to the v1.4 CocosSharp rendering engine to get that to work? It definitely used to keep animations running during background work.

    What am I doing wrong? Or is CocoSharp just single threaded now and there's no way around it.

  • ThomasEveringhamThomasEveringham USMember ✭✭

    Same problem here - it was an absolute nightmare to debug this. So comforting to find this thread.. I'm not alone :')

    Any progress on this?

Sign In or Register to comment.