Calling a method from an event handler crashes FBO allocation

This is a strange one (at least to me)

I have a method that creates a new object from a class and in so doing saves an image using an FBO. It all works fine.

However, if this method is called from inside an ofxLibwebsockets onMessage handler, the app crashes when trying to allocate the FBO. Remove the FBO part and everything is fine. Im guessing this is something to do with the method being called from inside the handler?

Any help would be much appreciated.

Hi,

I’m not too familiar with ofxLibwebsockets, but you can’t do any OpenGL stuff outside of the main thread.
Is it possible this message it is responding to is triggered by another thread?

/A

Yeah I think that could be it - is there a way to call method via the main thread?

I usually end up setting a flag that I just check from the main thread, the update method in your ofApp or if you have subscribed to the update event that should be all good.

/A

Thought about that but wondered if there was another way. Cheers I’ll give that a go.

Did the flag approach and worked perfectly - thanks!