Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Android] Creating texture in thread crashes the app  (Read 1762 times)

0 Members and 1 Guest are viewing this topic.

BlueCobold

  • Full Member
  • ***
  • Posts: 105
    • View Profile
[Android] Creating texture in thread crashes the app
« on: October 21, 2015, 11:12:06 am »
Hi.

I got my game running on Windows, Linux, OS X and iOS, but I have an issue with Android. Whenever I create a texture inside a thread (which is used to load assets while still rendering/updating/animating the UI fluidly), the app crashes. Using current git branch "feature/system-handle". Mind that the following code works on the other 4 operation-systems without a problem.

Minimal sample:
#include <SFML/Window/Event.hpp>
#include <SFML/System/Thread.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Texture.hpp>

int main(int argc, char* argv[])
{
    sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "access violation in constructor");

    bool loaded = false;

    sf::Texture* tex;
    sf::Thread thread([&]()
    {
        tex = new sf::Texture(); // crashing in this line on Android only
        loaded = tex->loadFromFile("res/img/gui/Window.png");
    });

    thread.launch() ;

    while ( window.isOpen() )
    {
        sf::Event event ;
        while ( window.pollEvent(event) )
        {
            if ( event.type == sf::Event::Closed )
                window.close() ;
        }
        if(loaded)
            window.setTitle("Thread done, close now");
    }
    delete tex;

    return 0;
}
« Last Edit: October 21, 2015, 11:19:32 am by BlueCobold »

BlueCobold

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: [Android] Creating texture in thread crashes the app
« Reply #1 on: October 21, 2015, 12:20:55 pm »