I have a legacy project that has been updated to Unity 2020.1.0f1 and I’m able to create a PC/Mac standalone build successfully.
But, if I try to create a WebGL build, Unity is generating the old “.asm” version of the files: (WebGL.asm.framework.js, WebGL.asm.js, WebGL.asm.loader.js, WebGL.asm.mem, WebGL.data).
But it should be generating the newer “.wasm” files: (WebGL.framework.js, WebGL.loader.js, WebGL.wasm, WebGL.data). Which it does, if a create a 3D project from scratch with this Unity version.
The change needs to be placed to a Unity Editor side script, not in a Unity Player time script. Check the attached buildWebGL.cs script for one way how to do that, see the instruction inside the file.
You can run the dropdown “HTML5 Export/Wasm+Release uncompressed…”, which will flip the option from asm.js back to wasm.
Thanks a million for that help and the file you sent. It worked real good!
I was wondering if I could pass it on to Rocco at Simmer.io? I’ve got my legacy WebGL simulator running on his site right now - but for a while, I was telling him that I couldn’t figure out why my WebGL builds were not the newer kind that Simmer.io requires.
Perhaps I should have mentioned that it was a legacy project. He might have been aware of the file fix that you have provided. And being able to turn off compression in the Editor is also real handy. Here’s the link to my Avatar Guitar Teacher simulator:
Thanks for the news about the file you provided. I’ll pass it on to Rocco. And thanks for the compliment about the project. Playing the guitar with the mouse is next!
But I’m curious when you say it’s running at a solid 360 fps. For me, the FPS display in my UI always maxes out at 60 fps. Is there another way to view a different fps number in a browser? I’ve got the same app running as a PC/Mac standalone version and on my older laptop it’s cranking out almost 500 fps with the left window full-screen at start-up! And if I shrink the screen about a quarter size (about 1000 x 500) it puts out over 1200 fps!
I need this level of calculated fps to reduce the timing errors when using the sequencer to play the guitar with really short notes (1/64) and at really fast tempos (360 bpm).
WebGL builds are capped in the browser at your monitor’s refresh rate by default. Not sure how you can unlock it though… and now I am wondering if Jukka has a 360hz monitor!
@jukka_j regarding controlling FPS not as a debug feature(which should be in the browser), how about allowing the control of FPS using Application.targetFrameRate ?
Let’s say that we have a display of 60hz, and we want to run at 30 FPS, isn’t it possible in the emscripten level to check the time between the requestAnimationFrame calls, and skipping the Unity update/render call if the delta is smaller than the delta of the required frame rate?
Yes, that support is there already today (need to also set QualitySettings.vsyncCount to 0 to disable vsync). In future Unity updates it will work better by also allowing frame rate decimation (render every other vsync, every third, every fourth, etc.)
I’m having a similar problem with my 2D game. Dropped the provided script into my Editor folder (except it was in my Library, there was no discoverable Editor folder in Assets in Unity 2020.2)
But now Im getting an error in Unity that “Asset Packages/com.unity.timeline/Editor/buildWebGL.cs has no meta file, but it’s in an immutable folder. The asset will be ignored.”
I tried changing the folder permission off of ReadOnly, except whenever I reopen the window it just goes back to readonly. Like OP I wanna load this to Simmer.io and this is driving me crazy.
You might have to create an Editor folder in the Assets folder, then put the buildWebGL.cs file there. At least, that’s what worked for me. I’ve attached a snapshot of the Editor (Unity 2020.1.11f1) showing the new “HTML 5 Export” tab and the drop-down selection I use to build a WebGL package for Simmer.io.
Question: How many creators do you think run in the exact same problem, that their old projects are still built with asm and searching for how they can change that to wasm?
Do you really think over there at unity, that every removed checkbox from the GUI makes things simpler and easier? Here is another example that this is not the case.
The issue here is that the script was placed to the wrong directory. If the directory /Assets/Editor does not exist, it should be created. Adding the build script under com.unity.timeline package will not help.
We have not had many reports about this issue, suggesting that it is not common issue to happen. This change happened about two years before I joined Unity WebGL team, and my impression here is that the difficulty was that there were some users that do need the asm.js build to still function, which is why the update did not automatically convert existing projects over.
With the next toolchain update, asm.js support will go away altogether (google dropped support for it), so at that point, we will either error, or autoconvert projects.
No, we do not think that. Btw, what was the first example of a removed checkbox that made life harder? Just curious.
Regarding upgrading projects from 2018 to 2019, we also faced those issues(ASM.JS vs WASM and the hidden option), and when we talked about it with Marco at Unite 2019, as far as I remember, Unity weren’t aware of that at the time.
In our case, we expected the build to now run using WASM, as the option was dropped from the GUI, but it kept on using ASM.JS… (we even set “wasm streaming” enable)
I think that it’s a general issue when upgrading Unity projects, and it’s more product related than platform related.
If options that are being used become hidden, when upgrading the project, the editor should notify about this specific change.
And if ASM.JS is going to be deprecated, and the developer still use it under the hood (by mistake or intentionally), maybe as long as he uses it, have a warning about it on the console window.
@jukka_j I have tried to modify the ProjectSettings.asset file and set: webGLLinkerTarget: 0 but Unity still builds it to wasm instead of asm.js. I also did that using an Editor script, a button that does:
if(GUILayout.Button("Set to ASM", GUILayout.Height(40)))
{
PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Asm;
}
Still it builds to Wasm, forget the both option which is what I exactly want.
The issue is with iPhone 6 as the client can not run it on their phone, the game crashes once the WebGL loader has finished loading (at starting unity instance moment / loading or starting actual game once the data is downloaded)