Details
-
Task
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.15
-
None
Description
We have a chat view which can show several animated images (loading animation). In combination with slots being called frequently on the main thread, this can lead to bad performance up to freezing.
This is due to emscripten libraries which execute the event queue during mutexes. We manually patched emscripten to avoid deadlocks due to this, this means many of the events are kept in the event queue until the rendering returns to the main loop. This can make the problem even worse.
Analysis has shown that during rendering often memory is allocated via dlmalloc/dlfree which then uses a mutex to get the memory. The mutex then causes slowdowns due to event processing. The problem gets worse the more events are send to the queue (e.g. from background threads).
The suggested solution would be to have either an optimisation of the memory management in emscripten (which is preferable) or a custom memory pool per thread to avoid that for each allocation a mutex is required.
At the time of writing we use emscripten 2.0.6.