XaoS icon indicating copy to clipboard operation
XaoS copied to clipboard

Compile XaoS for the web via Qt

Open kovzol opened this issue 4 years ago • 0 comments

On Feb 6 I managed to compile XaoS as recommended at https://wiki.qt.io/Building_Qt_5_from_Git https://wiki.qt.io/Qt_for_WebAssembly https://doc.qt.io/qt-5/wasm.html Both Firefox and Chrome is freezing on the startup: image But after a few seconds when Firefox asks if the process should be stopped, the init screen of XaoS is shown properly (interaction and running is however not possible): image This is very promising for the first attempt, I think we will be able to run XaoS in the browser in a reasonable time.

More info added later: Some update... Meanwhile I learned that Qt can be compiled as pthread-capable and non-pthread-capable. The second one is the default. Unfortunately, Firefox no longer supports the first one out-of-the-box, but Chrome does. But I think we can disable thread support by removing USE_PTHREADS for the WebAssembly build.

Actually I still have no luck in making XaoS run in a browser, and thread handling is not the problem. It is clear that the main loop in MainWindow::eventLoop() is working, but for some reason the canvas will be actually never drawn. Only Firefox draws the final state of the canvas after I force the main loop to stop (when Firefox asks me to do that because the app is not responding). I assume that this kind of loop is incompatible with the WebAssembly approach, but not completely sure yet.

At https://github.com/msorvig/qt-webassembly-examples/tree/master/gui_opengl there is a quite minimal example that properly works in my Linux natively and also with the browser... I am afraid that the solution we currently use in XaoS is not supported in a browser at all---making an infinite loop with for(;;) is something that kills the browser resources since it is something synchronous. I guess we may need to think in asynchronous events.

JB's response:

Yes, I think that the event loop needs to be redone the Qt way. I was planning to do that anyway at some point but was going to wait until after 4.0. I think that probably the right way to do it for XaoS is to use a QTimer to fire periodically and call the UIH functions to update the fractal.

kovzol avatar May 05 '20 08:05 kovzol