Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unity 2021.2 support, Emscripten 2

See original GitHub issue

I tried to test webxr-export with Unity 2021.2, currently at beta 9, as it has new Emscripten 2.0.19 and overall improved Web builds that have worked well for us in general, in tests so far.

There are some changes that were needed for the build, and after fixing those am now encountering a runtime error. I don’t expect support for the beta but figured it would be useful to share the notes for info. I can make a branch with the changes if that’s considered useful, now that hacked it locally.

  1. Pointer_stringify is no more, simple search-replace to UTF8ToString fixes this
  2. BrowserObject.pauseAsyncCallbacks(); is also deprecated, and all I found was a hint to just remove it, so I commented that and the resume call likewise, for example there in webxr.jspre
XRManager.prototype.onRequestARSession = function () {
        if (!this.isARSupported) return;
        var thisXRMananger = this;
        var tempRender = function () {
          thisXRMananger.ctx.clearColor(0, 0, 0, 0);
          thisXRMananger.ctx.clear(thisXRMananger.ctx.COLOR_BUFFER_BIT | thisXRMananger.ctx.DEPTH_BUFFER_BIT);
        window.requestAnimationFrame( tempRender );
        navigator.xr.requestSession('immersive-ar', {
          requiredFeatures: thisXRMananger.gameModule.WebXR.Settings.ARRequiredReferenceSpace,
          optionalFeatures: thisXRMananger.gameModule.WebXR.Settings.AROptionalFeatures
        }).then(function (session) {
          session.isImmersive = true;
          session.isInSession = true;
          session.isAR = true;
          thisXRMananger.xrSession = session;
        }).catch(function (error) {

Now it builds and starts without error, but trying to tap the screen leads to an error with touch event handlers - didn’t figure that out (yet, and may not have time to return on this soon). Oh except now I was not able to reproduce the error, I tried to fix it with the if for null/undefined check there, but earlier got the error still anyhow, about an undefined param there with touch handlers:

this.SendTouchEvent = function(JSEventsObject, eventID, eventName, target, changedTouches) {
          var touchEvent = new XRTouchEvent(eventName, target, this.touches, this.touches, changedTouches);
          var handler = JSEventsObject.eventHandlers[eventID];
          if (handler && handler.eventListenerFunc)

Will post more info when get to test more, and indeed can make a branch, unless folks figure it’s best to wait or so.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

antontcommented, Sep 28, 2021

Got to reproduce the .jspre one with his minimal case, though it worked in a development build but got the bug in release mode. Submitted as a bug.

Am not sure if Unity should provide the bw compat for Pointer_stringify, maybe, haven’t followed really how they’ve dealt with those in Emscripten.

De-Panthercommented, Sep 27, 2021

I think that Marks already reported on the .jspre, but maybe not. I posted about the Pointer_stringify on the forum, but won’t have time to report a bug. If you have time to report on those bugs, please do. Also when you have the issue numbers, please post them on those forum threads.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manual: WebGL native plug-ins for Emscripten
From Emscripten 2.0 onwards, Unity recommends to build Wasm Object File plug-ins ... For versions before Unity 2021.2 (Emscripten 2.0), LLVM Bitcode file ......
Read more >
Manual: Upgrading to Unity 2021.2
This page lists changes in the Unity 2021.2 version which might affect existing projects when you upgrade from ... WebGL: Updated Emscripten to...
Read more >
Unity 2021.2.0
Unity 2021.2.0 download and release notes. ... Editor: Added support for two new menu states, "disabled" and "checked", in Unity Search.
Read more >
Unity 2021.2.0f1 webgl build failures - emscripten
Hello! I've migrated a project up to the unity 2021.2.0f1 that was working fine before in version 2021.1, and having issues building.
Read more >
0002220: [Unity] Update Emscripten to 2.0.19
In Unity 2021.2, the underlying Emscripten compiler used by the WebGL platform was updated to version 2.0.19. Previous versions of Unity ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found