Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: xr test automation #16204

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simonedevit
Copy link
Contributor

@simonedevit simonedevit commented Feb 23, 2025

The following PR proposes a solution to integrate WebXR automated tests.

Forum link: https://forum.babylonjs.com/t/webxr-test-automation/56736.


HOW TO CREATE A NEW TEST:

  1. Start Babylon server with HTTPS (*)
    npm run serve -w @tools/babylon-server
  2. Start Babylon playground with HTTPS (*)
    npm run serve -w @tools/playground
  3. Wear your headset (**)
  4. (headset) Go to https://{YOUR_LOCAL_IP}:1337/?local=true and accept authority certificates (required from HTTP calls by playground)
  5. (headset) Go to https://{YOUR_LOCAL_IP}:1338/?local=true#F41V6N#2096 and accept authority certificates
  6. (headset) Click on Settings icon Settings > "RECORD XR SESSION"
  7. As soon you enter in XR session, all actions (camera and controller movements) will be recorded
  8. (headset) Enter in XR session, click on the sphere with your right controller (**) and the sphere will become red. Press on "A" button of right controller to save your recorded actions in a file
  9. A file similar to F41V6N-2025-02-22_18_35_38.json will be saved in your device (for Oculus Quest 3 the folder is /sdcard/Download)
  10. Enable "Developer options", connect your device with ADB and copy the above file
  11. Past the file into packages/tools/tests/test/visualization/XRActions folder
  12. Add the file name (inclusive of extension) in actions attribute of your current test in packages/tools/tests/test/visualization/config.json, e.g.:
{
    "title": "VR Test",
    "playgroundId": "#F41V6N#2096",
    "isWebXR": true,
    "actions": "F41V6N-2025-02-22_18_35_38.json"
}
  1. Stop Babylon server and start it without HTTPS protocol
  2. Start visualization tests
    npm run test:visualization:ui
  3. Play your test

(*) I have set https: true directly in common Webpack configuration (packages/dev/buildTools/dist/webpackTools.js) rather than use the launch scripts (.vscode/launch.json).

(**) The test was executed on an Oculus Quest 3.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Building or testing the sandbox has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/16204/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Graph tools CI has failed you can find the test results at:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/TOOLS/refs/pull/16204/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Reviewer - this PR has made changes to one or more package.json files.

@simonedevit
Copy link
Contributor Author

I'm sorry, I thought I had created the pull request on my fork.

@simonedevit simonedevit reopened this Feb 23, 2025
@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Reviewer - this PR has made changes to one or more package.json files.

this._xrSessionManager.referenceSpace = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(transform);
let isIwerEmulator = false;
// @ts-expect-error - augment Window interface
if (window && window.xrDevice){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a robust condition to check if we are using Immersive Web Emulation Runtime?

if (window && window.xrDevice){
isIwerEmulator = true;
}
const offsetMatrix = isIwerEmulator ? transform.matrix : transform;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IWER doesn't accept an XRRigidTransform object but a mat4 (gl-matrix) package. Maybe this is not compliant to WebXR Device API specifications (https://www.w3.org/TR/webxr/#xrreferencespace-interface).

@@ -358,6 +360,9 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
globalObject.scene.then((s: Scene) => {
this._scene = s;
globalObject.scene = this._scene;
if (Utilities.ReadBoolFromStore("record-xr-session", false)){
this._addRecordActions();
}
});
} else {
this._scene = globalObject.scene as Scene;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add this._addRecordActions because XR session is always async.

@@ -113,12 +117,31 @@ export const evaluatePlaywrightVisTests = async (engineType = "webgl2", testFile
page.on("console", logCallback);
console.log("Running test: " + testCase.title, ". Meta: ", testCase.playgroundId || testCase.scriptToRun || testCase.sceneFilename);
test.setTimeout(timeout);
let xrActions = null;
if (testCase.isWebXR){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inject Immersive Web Emulation Runtime only if the current is an XR test case (this keep away potential regressions to other test cases for injecting a variable in the global object).

xrSessionManager.onXRReady.add(() => {
player = window.xrDevice.createActionPlayer(xrSessionManager.baseReferenceSpace, xrActions);
// rewrite stop function otherwise IWER's stop function restore camera and controllers to initial position
player.stop = () => { resolve(true) };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve the promise once that the execution of recorded actions is over but don't stop the player because stopping the player means restore camera and controllers to initial position. Image scenario where you execute a lot of actions (e.g.: you move in the space) and you need to check/test the final view not the first one).

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/16204/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Building or testing the sandbox has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/16204/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Graph tools CI has failed you can find the test results at:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/TOOLS/refs/pull/16204/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Building or testing the sandbox has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/16204/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/16204/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 23, 2025

Graph tools CI has failed you can find the test results at:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/TOOLS/refs/pull/16204/merge/testResults/

@RaananW
Copy link
Member

RaananW commented Feb 23, 2025

Hi and thanks for the PR!

Playwright allows us to install extensions on CI agents, so this is the solution I would pursue. I don't want to make any changes to the XR classes just for the sake of testing.

The changes made in this kind of PR should be minimal - XR should work the same as any other test just with an extra click on the XR button.

Also, as a side note - dual screen would make more sense, because we do have sometimes issues of things rendering incorrectly on the second render pass.

It's a future task of mine, but I still didn't dive too deep into that. There is also the fact that we are testing on browserstack (which might change the test scenario if they don't allow us to install plugins).

@simonedevit
Copy link
Contributor Author

Thank you for your response!

I'm really glad to hear that this is one of your future tasks because i want to learn a lot from you! I am completely agree not wanting to modify XR classes just for testing purposes, my suggestion was just an assumption to get the job done.

Also, as a side note - dual screen would make more sense, because we do have sometimes issues of things rendering incorrectly on the second render pass.

Thank you for the tip! I hadn’t considered that rendering issues might occur on the second pass, definitely something to keep in mind.

Feel free to close the pull request if you think it's appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants