Unity 2021.2 support, Emscripten 2
See original GitHub issueI 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.
- Pointer_stringify is no more, simple search-replace to UTF8ToString fixes this
- 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;
//this.BrowserObject.pauseAsyncCallbacks();
this.BrowserObject.mainLoop.pause();
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;
thisXRMananger.onSessionStarted(session);
}).catch(function (error) {
//thisXRMananger.BrowserObject.resumeAsyncCallbacks();
thisXRMananger.BrowserObject.mainLoop.resume();
});
}
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)
handler.eventListenerFunc(touchEvent);
}
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:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
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.I think that Marks already reported on the
.jspre
, but maybe not. https://forum.unity.com/threads/jspre-files-being-ignored-webgl.1174493/ I posted about thePointer_stringify
on the forum, but won’t have time to report a bug. https://forum.unity.com/threads/changes-in-unity-2021-2-beta-13-pointer_stringify.1174661/ 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.