Emit asm.js code into a dedicated file for asm.js export
This helps prevent browser lockups during start-up at the cost of having to distribute an extra file.
This commit is contained in:
parent
17422f1f86
commit
5ede1a1226
|
@ -91,6 +91,7 @@ def configure(env):
|
||||||
env.Append(LINKFLAGS=['--compression', lzma_binpath + "," + lzma_decoder + "," + lzma_dec])
|
env.Append(LINKFLAGS=['--compression', lzma_binpath + "," + lzma_decoder + "," + lzma_dec])
|
||||||
|
|
||||||
env.Append(LINKFLAGS=['-s', 'ASM_JS=1'])
|
env.Append(LINKFLAGS=['-s', 'ASM_JS=1'])
|
||||||
|
env.Append(LINKFLAGS=['--separate-asm'])
|
||||||
env.Append(LINKFLAGS=['-O2'])
|
env.Append(LINKFLAGS=['-O2'])
|
||||||
# env.Append(LINKFLAGS=['-g4'])
|
# env.Append(LINKFLAGS=['-g4'])
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& p_html, const St
|
||||||
current_line = current_line.replace("$GODOT_FS",p_name+"fs.js");
|
current_line = current_line.replace("$GODOT_FS",p_name+"fs.js");
|
||||||
current_line = current_line.replace("$GODOT_MEM",p_name+".mem");
|
current_line = current_line.replace("$GODOT_MEM",p_name+".mem");
|
||||||
current_line = current_line.replace("$GODOT_JS",p_name+".js");
|
current_line = current_line.replace("$GODOT_JS",p_name+".js");
|
||||||
|
current_line = current_line.replace("$GODOT_ASM",p_name+".asm.js");
|
||||||
current_line = current_line.replace("$GODOT_CANVAS_WIDTH",Globals::get_singleton()->get("display/width"));
|
current_line = current_line.replace("$GODOT_CANVAS_WIDTH",Globals::get_singleton()->get("display/width"));
|
||||||
current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",Globals::get_singleton()->get("display/height"));
|
current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",Globals::get_singleton()->get("display/height"));
|
||||||
current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:(String) Globals::get_singleton()->get("application/name"));
|
current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:(String) Globals::get_singleton()->get("application/name"));
|
||||||
|
@ -323,6 +324,11 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool
|
||||||
file=p_path.get_file().basename()+".js";
|
file=p_path.get_file().basename()+".js";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file=="godot.asm.js") {
|
||||||
|
|
||||||
|
file=p_path.get_file().basename()+".asm.js";
|
||||||
|
}
|
||||||
|
|
||||||
if (file=="godot.mem") {
|
if (file=="godot.mem") {
|
||||||
|
|
||||||
//_fix_godot(data);
|
//_fix_godot(data);
|
||||||
|
|
|
@ -354,21 +354,30 @@
|
||||||
<script type="text/javascript" src="$GODOT_FS"></script>
|
<script type="text/javascript" src="$GODOT_FS"></script>
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
var memoryInitializer = "$GODOT_MEM";
|
var script = document.createElement('script');
|
||||||
if (typeof Module.locateFile === "function") {
|
script.src = "$GODOT_ASM";
|
||||||
memoryInitializer = Module.locateFile(memoryInitializer);
|
script.onload = function() {
|
||||||
} else if (Module.memoryInitializerPrefixURL) {
|
setTimeout(function() {
|
||||||
memoryInitializer = Module.memoryInitializerPrefixURL + memoryInitializer;
|
(function() {
|
||||||
}
|
var memoryInitializer = '$GODOT_MEM';
|
||||||
var xhr = Module.memoryInitializerRequest = new XMLHttpRequest();
|
if (typeof Module.locateFile === 'function') {
|
||||||
xhr.open("GET", memoryInitializer, true);
|
memoryInitializer = Module.locateFile(memoryInitializer);
|
||||||
xhr.responseType = "arraybuffer";
|
} else if (Module.memoryInitializerPrefixURL) {
|
||||||
xhr.send(null);
|
memoryInitializer = Module.memoryInitializerPrefixURL + memoryInitializer;
|
||||||
})();
|
}
|
||||||
|
var xhr = Module.memoryInitializerRequest = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', memoryInitializer, true);
|
||||||
|
xhr.responseType = 'arraybuffer';
|
||||||
|
xhr.send(null);
|
||||||
|
})();
|
||||||
|
|
||||||
var script = document.createElement("script");
|
var script = document.createElement('script');
|
||||||
script.src = "$GODOT_JS";
|
script.src = "$GODOT_JS";
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
|
}, 1); // delaying even 1ms is enough to allow compilation memory to be reclaimed
|
||||||
|
};
|
||||||
|
document.body.appendChild(script);
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue