fix headless windows

This commit is contained in:
Evan Almloff committed 2023-12-08 15:14:32 -06:00
1 parent 0e3fd225a8
commit 8984482b63
4 files changed
+18 -9

No files matched your search

+10 -4
View File
@@ -51,15 +51,21 @@ fn main() {
}"#;
let polling_request = format!(
r#"// Poll for requests
window.interpreter.wait_for_request = () => {{
window.interpreter.wait_for_request = (headless) => {{
fetch(new Request("{EDITS_PATH}"))
.then(response => {{
response.arrayBuffer()
.then(bytes => {{
requestAnimationFrame(() => {{
// In headless mode, the requestAnimationFrame callback is never called, so we need to run the bytes directly
if (headless) {{
run_from_bytes(bytes);
}});
window.interpreter.wait_for_request();
}}
else {{
requestAnimationFrame(() => {{
run_from_bytes(bytes);
}});
}}
window.interpreter.wait_for_request(headless);
}});
}})
}}"#