engine icon indicating copy to clipboard operation
engine copied to clipboard

Camera Indexing Bug: Huawei Meta 80 Rear Camera unreachable in WeChat / Zoomed-in in Chrome

Open MVC-Yanis opened this issue 7 months ago • 3 comments

Dear 8thWall Support,

We are facing a critical camera mapping issue on the Huawei Meta 80 (HarmonyOS). Our standard WebAR project works perfectly on iOS but fails on this specific hardware.

  1. The Problem:

WeChat (X5 Kernel): Opens the Front camera by default. Even with cameraDirection: BACK or a specific deviceId, it remains stuck on the front view.

Chrome: Opens the Telephoto lens (extreme zoom) instead of the Primary Wide lens.

  1. Technical Evidence:

WebRTC Test: A standard getUserMedia test confirms the Rear Camera is at Index 0 on this device.

XR8 Conflict: The 8thWall Camera Pipeline appears to skip Index 0 or misidentify it as a front sensor, causing a fallback to the actual front camera.

Manual Override: Using onBeforeRun to force config.cameraConfig.id does not override this behavior in WeChat.

  1. Request: Could you please verify the camera indexing logic for the Huawei Meta 80? We need to be able to force the engine to use Index 0 (Primary Rear) without it being overridden by internal SLAM filtering.

Attached: Console logs and device hardware info.

Best regards

MVC-Yanis avatar Apr 23 '26 07:04 MVC-Yanis

I don't see any attached logs or hardware info.

Some context from discord

The logic here is responsible for specifying the camera constraints: https://github.com/8thwall/8thwall/blob/main/reality/app/xr/js/src/constraints-helper.ts#L204

If the camera names don't match the expected format, and the == 'Android' check is not matching, there might need to be a tweak to that logic to support harmony OS.

If you build from source and add some debugging, you can probably get an idea of what we need to tweak - would appreciate a contribution once you have it working!

https://github.com/8thwall/8thwall/blob/main/CONTRIBUTING.md#local-development https://github.com/8thwall/8thwall/tree/main/packages/engine#running

After calculating and applying the true FOV with this method, the spatial tracking stability has improved significantly on my devices. Really appreciate your help and guidance!

You may also want to explore replacing the getUserMedia method with a wrapper function that adds the necessary parameters:

const originalGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices)
const customGetUserMedia = (constraints) {
   if (constraints.video) {
    constraints.video.facingMode = {exact: 'environment'}
    // or could specify device ID directly if you have a better number
  }
  return originalGetUserMedia(constraints)
}
navigator.mediaDevices.getUserMedia = customGetUserMedia

cmbartschat avatar Apr 23 '26 15:04 cmbartschat

Is there any information you can provide that will help others solve this problem?

cmbartschat avatar Apr 27 '26 15:04 cmbartschat

Is there any information you can provide that will help others solve this problem?

yes To address the incompatibility issues with Huawei's HarmonyOS, I simply spoofed 8th Wall by modifying navigator.userAgent to Android 12.
.`(function() { const ua = navigator.userAgent; if (ua.includes('OpenHarmony') || ua.includes('ArkWeb')) { console.log("[Fix] ..."); try { Object.defineProperty(navigator, 'userAgent', { get: () => ua + " Android 12; Mobile;", configurable: true }); } catch (e) { console.error("UA failed:", e); }

    const originalGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
    navigator.mediaDevices.getUserMedia = async (constraints) => {
        if (constraints && constraints.video) {
            constraints.video.facingMode = { exact: 'environment' };
        }
        return originalGetUserMedia(constraints);
    };
} else {
    console.log("[System] iPad/Chrome");
}

})();`

MVC-Yanis avatar May 07 '26 10:05 MVC-Yanis