Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when trying to load HTML5 build from local filesystem #7463

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions engine/engine/content/builtins/manifests/web/engine_template.html
Expand Up @@ -69,6 +69,11 @@
</head>

<body>
<div id="running-from-file-warning" style="display: none; margin: 3em;">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we exclude it for release?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. Or have it as an option in game.project?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm maybe, but in this case user will never know we have something like this in index.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One concern I have with removing this warning in a release build is that a beginner might export a release build and try to double-click on index.html and end up in the same situation as we're trying to resolve.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

<h1>Running from local file ⚠️</h1>
<p>It seems like you have opened this file by double-clicking on it. In order to test your build in a browser <b>you need to load this file from a web server</b>. You can either upload this file and the rest of the files from a Defold HTML5 bundle to a web hosting service OR host them using a local web server on your home network.</p>
<p><a href="https://defold.com/manuals/html5/#testing-html5-build" target="_blank">Learn more about running a local web server in the Defold HTML5 manual</a>.</p>
</div>
<div id="app-container" class="canvas-app-container">
<div id="canvas-container" class="canvas-app-canvas-container">
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="{{display.width}}" height="{{display.height}}"></canvas>
Expand Down Expand Up @@ -204,8 +209,15 @@
</script>

<script id='engine-start' type='text/javascript'>
EngineLoader.stream_wasm = "{{html5.wasm_streaming}}" === "true";
EngineLoader.load("canvas", "{{exe-name}}");
var runningFromFileWarning = document.getElementById("running-from-file-warning");
if (window.location.href.startsWith("file://")) {
runningFromFileWarning.style.display = "block";
}
else {
EngineLoader.stream_wasm = "{{html5.wasm_streaming}}" === "true";
EngineLoader.load("canvas", "{{exe-name}}");
runningFromFileWarning.parentNode.removeChild(runningFromFileWarning);
}
</script>
</body>
</html>