I would like to create a component in a worker thread and pass it to the MessageManager to include it in the interface, once it’s constructed.
The Component uses an image and does some drawings with SVG, so this can be onerous for the Message Thread according to the size of the image.
As of Juce 5, by calling juce::Drawable::createFromImageData() from the worker thread, the program hits an assertion (ASSERT_MESSAGE_MANAGER_IS_LOCKED) in juce::Component::internalRepaintUnchecked().
I would like to know:
- If it’s bad practice anyway to create a Component in a thread other than the Message Thread, even though it is passed later on to the Message Thread in order to be added to the GUI.
- If I can somehow by-pass the assertion in case there is no dangerous side effect in point 1
- If there are indeed any side effects, how could I create an “heavy” component without freezing the Message Thread ?