Add imgui_bundle package#116
Conversation
bbe1484 to
3a31fb1
Compare
|
Hello @ryanking13 , Following the merge of the WebGL2 PR, I rebased this PR. |
a556bf7 to
da1475e
Compare
Package Build ResultsTotal packages built: 35 Package Build Times (click to expand)
Longest build: imgui-bundle (5m 48s) |
|
I had to do some modifications in order to correct the test. Sorry for force-pushing several times today.
However, even with a virtual display headless there are remaining issues around requestAnimationFrame in Firefox, so the test is still expected to fail. Of course when deployed, the package and the apps developed with it will work on Safari / Firefox / Chrome (this was tested on Windows, Linux, macOS and iOS). |
agriyakhetarpal
left a comment
There was a problem hiding this comment.
Thanks for this work, @pthom! I am onboard with the testing criteria you proposed; I think it's a unique approach. Even if the tests work only for Chrome and not Firefox Headless, that is fine with me. I will wait for @ryanking13's comments/approval here.
There was a problem hiding this comment.
The test runs now correctly in Chrome.
Yeah, I think it is okay to test it only in Chrome. We don't expect to test the full functionality of the packages in this repository anyways. If we have more packages that require WebGL, let's consider including it in our CI environment, for now it looks okay.
| import time | ||
| deadline = time.time() + 6.0 # 6-second safety net (requestAnimationFrame may run slowly in headless mode) | ||
| while not done and time.time() < deadline: | ||
| time.sleep(0.05) # yields to JS -> lets requestAnimationFrame run |
There was a problem hiding this comment.
yields to JS
It won't. When JSPI is not enabled, time.sleep is busy wait.
You can use asyncio.sleep instead to ensure yielding to JS.
There was a problem hiding this comment.
Thanks!
I replaced this with
import asyncio, time
deadline = time.time() + 6.0 # 6-second safety net (requestAnimationFrame may run slowly in headless mode)
async def _wait_until_done():
while not done and time.time() < deadline:
await asyncio.sleep(0.05)
asyncio.run(_wait_until_done())Build notes:
------------
meta.yaml/build will trigger the build of SDL2 and libtml5 with -fPIC
Test notes:
-----------
* The test runs correctly in Chrome.
* The test is expected to fail in Firefox Headless because:
* Firefox Headless does not support WebGL unless a virtual display is set up.
This might be solved by adding a step in the GitHub Actions workflow to install xvfb + GL drivers.
* However, even with a virtual display headless there are remaining issues around requestAnimationFrame
so the test is still expected to fail.
For info, Xvfb + GL drivers might be installed by adding this into the build.yml CI workflow
- name: Start virtual display (for WebGL tests)
run: |
sudo apt-get update
sudo apt-get install -y xvfb libgl1-mesa-dri
Xvfb :99 -screen 0 1280x720x24 -ac &
echo "DISPLAY=:99.0" >> $GITHUB_ENV
7e56e1a to
67af758
Compare
|
@ryanking13 : I did all the changes you asked for. |
| async def _wait_until_done(): | ||
| while not done and time.time() < deadline: | ||
| await asyncio.sleep(0.05) | ||
|
|
||
| asyncio.run(_wait_until_done()) |
There was a problem hiding this comment.
It is worth noting that aysncio.run also works only if the JSPI is enabled.
So a safer way would be changing the test function to async, and simply using await asyncio.sleep(0.05). But we enable JSPI in our CI anyways, so probably it is okay.
|
Thank you! |
Description
Dear ImGui Bundle provides python bindings for Dear ImGui and lots of related libraries.
This PR adds support for the imgui_bundle package to Pyodide. It enables high-performance interactive GUIs (including 3D plotting, Markdown rendering, and immediate mode controls) directly in the browser using pure Python (no need for JavaScript, CSS, or WebAssembly glue code outside Pyodide’s core).
Demo
I prepared two demonstrations in order to showcase what is possible:
Discussion and related PR
This recipe requires a change inside pyodide/Makefile.envs (see technical note below: add -sMAX_WEBGL_VERSION=2).
A related PR was posted to the main pyodide repo, to add this flag.
The test for this new recipe will fail if this change is not applied.
Technical Notes:
Build configuration for Pyodide: -sMAX_WEBGL_VERSION=2
Link with SDL2 (fPIC):
meta.yaml/build will trigger the build of SDL2 and libtml5 with -fPIC