Hello,
Hope you guys are doing well.
I’m experiencing an issue with BabylonJS WebXR implementation that works correctly in my local development environment but fails when deployed to production. Both environments are being tested on the same device, so browser compatibility issues seem unlikely.
Please note that I am using babylonjs/core: 7.50.0
Looking at the error stack trace, it seems the issue happens specifically in the ConstructFeature
internal method of BabylonJS. The error occurs when trying to access property ‘1’ of an undefined value.
Here’s the relevant part of my implementation:
private enableARFeatures(featureManager: WebXRFeaturesManager): void {
if (!this.xrExperienceHelper) {
console.error(
"ARExperience : enableARFeatures : No WebXRExperienceHelper found!"
);
return;
}
// Enable WebXR DOM Overlay
featureManager.enableFeature(
WebXRFeatureName.DOM_OVERLAY,
1,
{
element: `#` + `${this.domOverlayID}`,
},
undefined,
false
) as WebXRDomOverlay;
// Enable Hit test
this.xrHitTest = featureManager.enableFeature(
WebXRFeatureName.HIT_TEST,
"latest"
) as WebXRHitTest;
}
Entering XR :
await this.xrExperienceHelper
.enterXRAsync("immersive-ar", "unbounded" /*, optionalRenderTarget */)
.then(() => {
console.info(
"GL : ARExperience : initializeAR : AR Permission Granted"
);
this.callback?.(ARState.AR_PERMISSION_GRANTED);
})
.catch((error) => {
console.error("GL : ARExperience : initializeAR : catch : ", error);
if (error?.message?.toLocaleLowerCase().includes("not supported")) {
this.callback?.(ARState.NOT_SUPPORTED);
} else {
this.callback?.(ARState.AR_PERMISSION_NOT_GRANTED);
}
});
Tagging the expert @RaananW