Try to use requestAnimationFrame for rendering

This commit is contained in:
Themba Dube 2019-07-22 17:38:32 -04:00
parent 9d66827e1c
commit f43245a706
2 changed files with 11 additions and 8 deletions

View File

@ -104,7 +104,10 @@
/* Load the screen */
"lv.scr_load(scr)"
];
var the_mp_handle_pending;
function handle_pending() {
the_mp_handle_pending();
}
/*Initialization function*/
function startRunning() {
/*Setup printing event handler*/
@ -121,21 +124,17 @@
decompressScript(compressedScript);
/*Setup lv_task_handler loop*/
var the_mp_handle_pending = Module.cwrap('mp_handle_pending', null);
function handle_pending() {
the_mp_handle_pending();
setTimeout(handle_pending, 10);
}
the_mp_handle_pending = Module.cwrap('mp_handle_pending', null);
/*Initialize the REPL.*/
mp_js_init_repl();
/*Start the main loop, asynchronously.*/
handle_pending();
window.top.reenableButton();
}
window.onload = function() {
console.log("onload");
startRunning();
window.top.beginAnimationLoop();
}

View File

@ -118,6 +118,10 @@
<script>
var editor, iframe;
var script_passed = false;
function beginAnimationLoop() {
iframe.contentWindow.handle_pending();
window.requestAnimationFrame(beginAnimationLoop);
}
// Ctrl+L is mandatory ! need xterm.js 3.14+
function xterm_helper(term, key) {
function ESC(data) {