WASM & Delphi

I’ve found 2 Samples, Pong & Canvas but they do not run either from my local computer nor when put on a server. The structure seems to be:
Pong (a Folder)
index.html
wasm (sub folder)
Pong.d.ts
Pong.js
Pong.wasm
RemObjectsElemens.js

The error reported is Pong.wasm not found, failed to load, etc.

Hi

Where did you find these samples, and how are you trying to run them — from the IDE (Fire, Water or Visual Studio), or standalone? What version of Elements are you using?

Does the following docs topic (which explains how all the files should fit together) shed some light onto what might be wrong? Are file relative oaths from the .html to the .js and .wasm files correct, and/or do you see any messages in the debug console?

http://docs.elementscompiler.com/Platforms/WebAssembly/Deployment/

thanx,
marc

I don’t have Water or any version of Elements, only copied from GetHub & tried to deploy.
I don’t really care about these particular samples, but would dearly love to see some Delphi written wasm project sample that runs before I do a trial & spend hrs trying to figure out how it works.

For some reason the <head . . . /head> elements & lines did not show, but are in index.html file:

	<script lang="javascript" src="wasm/RemObjectsElements.js"></script>
	<script lang="javascript" src="wasm/Pong.js"></script>

They came from GetHub(?) as samples I think I got from RemObjects page days ago.
the index file & the folder layout seems to agree with your link:
index.html:

WASM Pong
<body>
<h1>WASM Pong</h1>

<div id="stage" style="width:800px; margin:0 auto;"</div>
<script lang="javascript">
	var program;
	var thetimer;
	var ticks;
	Pong.instantiate("wasm/Pong.wasm").then(function (result) {
   // *** I added the Browser error msg below, not in the index.html file when run ***
    // /Pong/wasm/Pong.wasm:1 Failed to load resource:  
    // the server responded with a status of 404 (Not Found)
		console.log("WebAssembly file Pong.wasm has been loaded.");
		program = result.Program();
		program.Main();
	});

, , ,

Well, for one, you’d there be missing the binary .wasm file, which you’ll only get when you build the project. You’ll need to build the projects with Elements (in the IDE or from the command line) to get the .wasm file.

That said, the document I linked before should explain what relative folders things have to go in on your web server for things to work (note that you cannot load WASM from a local file:// URL — that’s a browser restriction, not ours).

I thought the binary was the Pong.wasm file & it should run on a Server with Pong.wasm in the wasm folder with the js files & below the index.html folder?

It is, yes.

I’d be able to help you better if I know what the exact sample is you’re looking at and where you got it from. As far as I recall, this is not one in our main samples repro (and if it was, the .wasm binary would not be committed as part of it).

Maybe it would be easiest if you could provide a link to a WASM/Delphi sample with all the files created so & can do nothing more than put on my server & watch it run. Of course with source code so I can figure out how to create my sample more like my project.
Then, with some confidence of the possibility, I would download the trial cc of Water to proceed to try to build a WASM project sample.

Here’s a new project as created from our template, and compiled; the source and binary is included. Once again, check the link I provided before for details how the files need to be deployed relative to each other.

WasmSample.zip (1008.7 KB)

You’re making yourself a lot more hassle than necessary though, as in Water, you could literally just do File|New project, hit Run, and see it working…

Thanks very much Marc. I’ll look at WasmSample.zip & then download Water & see “how sweet it is”.
Is this the place for a newbie to get help?

1 Like

:+1:t3:

Yes. Aside from the docs site I linked before, and our blogs, this here is our main community resource.

—marc

Same Problem. If I can’t deploy your sample I won’t be able to deploy mine.

Loaded project files & folders in WebStorm & won’t run with localhost either. Responds with 404.

What server type is this? Sure your server is enabled to serve wasm files? IIS for example only serves a restricted list of files by default. Can you access the wasm file directly by entering its url, or do you get a 404?

I’ll make sure to add a nite about this to our deployment topic tomorrow.

Win Server 2016. I did not know about or do anything to enable WASM. I’m a newbie on Win Server too. I only chose it cuz my previous project needed ISAPI for the speed. It is an AP with much logic & math not suited for JavaScript so separated into Client (HTML/CSS/JS) & Server ISAPI for the hard work. WASM looks so much better as the Client can do the hard stuff making a better Ap. My type of programming is better suited to DeskTop’s not Web stuff, but WASM makes it possible if I can get it to work.
I probably get a 404. And will check about IIS file type served. That may solve the problem.

It worked after setting mime type: wasm = application/wasm
You are my HERO! Thanks.

2 Likes

Glad I could help, and sorry for not thinking about this issue earlier - I had hit that myself a few weeks back, but forgot all about it. I’ll make sure we’ll get that documented tomorrow.

1 Like

Docs tropic is (was long been) updated btw: https://docs.elementscompiler.com/Platforms/WebAssembly/Deployment/Web/