Skip to content

Commit 34186fe

Browse files
bkaradzic-microsoftCopilotbkaradzic
authored
Bump JsRuntimeHost for File/FileReader polyfill (re-enables 19 GLTF/OBJ tests) (#1706)
Re-enables the 19 GLTF/OBJ serializer round-trip tests that fail under BN today because the runtime is missing `File` and `FileReader`. Babylon.js code paths (`new File([blob], 'scene.glb')` followed by `LoadAssetContainerAsync(file, scene)`, which internally reads via `FileReader.readAsArrayBuffer`) need both APIs to work. The actual polyfill **lives in JsRuntimeHost** ([bkaradzic-microsoft/JsRuntimeHost @ 670084e5](bkaradzic-microsoft/JsRuntimeHost@670084e)), next to `Polyfills/Blob/`. That's the architecturally correct home — `File` and `FileReader` are standard WHATWG web APIs in the same category as the existing `XMLHttpRequest` / `URL` / `WebSocket` / `TextDecoder` / `AbortController` polyfills hosted there, and `File` is layered directly on top of `Blob`. Hosting them there means every JsRuntimeHost consumer (BN and any other embedder) gets them. > Addresses [@bghgary's review](#1706 (review)): _"this should be a proper C++ polyfill under `Polyfills/` so every consumer gets it, not a Playground-only JS script"_. **This PR (BN-side) is intentionally tiny:** - `CMakeLists.txt` — bump JsRuntimeHost `GIT_TAG` to `670084e5` and temporarily point `GIT_REPOSITORY` at the [`bkaradzic-microsoft/JsRuntimeHost`](https://github.com/bkaradzic-microsoft/JsRuntimeHost) fork until the upstream JsRuntimeHost PR is merged. Will be re-pinned to a `BabylonJS/JsRuntimeHost` commit before this PR merges. - `Apps/Playground/Shared/AppContext.cpp` — `Babylon::Polyfills::File::Initialize(env)` immediately after `Blob::Initialize(env)`. The old `LoadScript("app:///Scripts/file_polyfill.js")` line is gone. - `Apps/Playground/CMakeLists.txt` — drops `file_polyfill.js` from SCRIPTS, links the new JsRuntimeHost `File` target into the Playground binary. - `Apps/Playground/Scripts/file_polyfill.js` — deleted (308 lines of JS subsumed by the C++ polyfill in JsRuntimeHost). - `Apps/Playground/Scripts/config.json` — re-enables 19 affected tests; adds `excludedGraphicsApis: ["OpenGL"]` to 5 GLTF Serializer tests (KHR gpu instancing + 4 Camera variants) for OpenGL-specific backend issues unrelated to this polyfill. **Verified:** 19/19 affected tests pass on Win32 D3D11 Release headless without `--include-excluded` (indices 208-216, 219-226, 275-276). Remaining 9 (in the same family) fail with separate root causes — tracked separately. ## Landing sequence 1. ✅ Push JsRuntimeHost work to fork branch + this BN PR (← here, validating CI against fork branch). 2. ⏳ Open PR to `BabylonJS/JsRuntimeHost` adding `Polyfills/File/` once BN CI is green here. 3. ⏳ After the JsRuntimeHost PR merges, re-pin this BN PR's `GIT_REPOSITORY` / `GIT_TAG` back to `BabylonJS/JsRuntimeHost` at the merged SHA. 4. ⏳ Merge this BN PR. --- ## Series landing context This PR is one of **7 splits** from the proven CI-green combined preview in **draft PR #1702** (see [#1702](#1702) for the full intended end-state and verified CI run [26044922430](https://github.com/BabylonJS/BabylonNative/actions/runs/26044922430)). > Note: the original split included an 8th PR (#1709, ES2020+ -> ES2019 syntax-repair polyfill for Chakra). It was closed in favour of investigating `@babel/standalone` properly (#1711). ### Recommended landing order **Tier 1 - parallel-reviewable, no source conflicts:** 1. #1703 - ExternalTexture C4702 build fix 2. #1704 - config.json `reason` rewrites (5 entries) 3. #1705 - config.json `reason` rewrites (17 entries) **Tier 2 - sequential, each touches `Apps/Playground/CMakeLists.txt` SCRIPTS list + `Apps/Playground/Shared/AppContext.cpp` LoadScript order; rebase the next branch after the previous merges:** 4. #1706 - File/FileReader polyfill (JsRuntimeHost bump + Playground wiring; largest test impact: 19 re-enables) 5. #1707 - fetch polyfill 6. #1708 - DOM globals + native AbortController + Android CMake link 7. #1710 - Cubemap auto-expand polyfill (loaded after babylon.max.js) ### Reference policy reminder Reference PNGs across all 7 PRs come from Babylon.js; never re-baked by BN. Combined diff: **0 PNGs**. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Branimir Karadzic <branimirkaradzic@gmail.com>
1 parent 1362eb0 commit 34186fe

5 files changed

Lines changed: 18 additions & 42 deletions

File tree

Apps/Playground/Android/BabylonNative/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ target_link_libraries(BabylonNativeJNI
3030
PRIVATE Blob
3131
PRIVATE Canvas
3232
PRIVATE Console
33+
PRIVATE File
3334
PRIVATE GraphicsDevice
3435
PRIVATE NativeCamera
3536
PRIVATE NativeCapture

Apps/Playground/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ target_link_libraries(Playground
140140
PRIVATE Canvas
141141
PRIVATE Console
142142
PRIVATE ExternalTexture
143+
PRIVATE File
143144
PRIVATE GraphicsDevice
144145
PRIVATE NativeCamera
145146
PRIVATE NativeCapture

Apps/Playground/Scripts/config.json

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,76 +1317,58 @@
13171317
"title": "GLTF Serializer with Negative World Matrix (left handed, once)",
13181318
"playgroundId": "#KX53VK#88",
13191319
"replace": "//options//, useRightHandedSystem = false; iterations = 1;",
1320-
"excludeFromAutomaticTesting": true,
1321-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13221320
"referenceImage": "glTFSerializerNegativeWorldMatrix.png"
13231321
},
13241322
{
13251323
"title": "GLTF Serializer with Negative World Matrix (left handed, twice)",
13261324
"playgroundId": "#KX53VK#88",
13271325
"replace": "//options//, useRightHandedSystem = false; iterations = 2;",
1328-
"excludeFromAutomaticTesting": true,
1329-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13301326
"referenceImage": "glTFSerializerNegativeWorldMatrix.png"
13311327
},
13321328
{
13331329
"title": "GLTF Serializer with Negative World Matrix (right handed, once)",
13341330
"playgroundId": "#KX53VK#88",
13351331
"replace": "//options//, useRightHandedSystem = true; iterations = 1;",
1336-
"excludeFromAutomaticTesting": true,
1337-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13381332
"referenceImage": "glTFSerializerNegativeWorldMatrix.png"
13391333
},
13401334
{
13411335
"title": "GLTF Serializer with Negative World Matrix (right handed, twice)",
13421336
"playgroundId": "#KX53VK#88",
13431337
"replace": "//options//, useRightHandedSystem = true; iterations = 2;",
1344-
"excludeFromAutomaticTesting": true,
1345-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13461338
"referenceImage": "glTFSerializerNegativeWorldMatrix.png"
13471339
},
13481340
{
13491341
"title": "GLTF Serializer Shared Buffer Conversions",
13501342
"playgroundId": "#KX53VK#85",
13511343
"replace": "//options//, meshCount = 2;",
1352-
"excludeFromAutomaticTesting": true,
1353-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13541344
"referenceImage": "glTFSerializerSharedBufferConversions.png"
13551345
},
13561346
{
13571347
"title": "GLTF Serializer Skinning and Animation",
13581348
"playgroundId": "#DMZBX1#1",
1359-
"excludeFromAutomaticTesting": true,
1360-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13611349
"referenceImage": "gltfSerializerSkinningAndAnimation.png"
13621350
},
13631351
{
13641352
"title": "GLTF Serializer Skinning and Animation (Right Handed)",
13651353
"playgroundId": "#DMZBX1#2",
1366-
"excludeFromAutomaticTesting": true,
1367-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13681354
"referenceImage": "gltfSerializerSkinningAndAnimation.png"
13691355
},
13701356
{
13711357
"title": "GLTF Serializer Morph Target Animation",
13721358
"playgroundId": "#84M2SR#107",
13731359
"renderCount": 2,
1374-
"excludeFromAutomaticTesting": true,
1375-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13761360
"referenceImage": "gltfSerializerMorphTargetAnimation.png"
13771361
},
13781362
{
13791363
"title": "GLTF Serializer Morph Target Animation Group",
13801364
"playgroundId": "#T087A8#29",
1381-
"excludeFromAutomaticTesting": true,
1382-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
13831365
"referenceImage": "gltfSerializerMorphTargetAnimationGroup.png"
13841366
},
13851367
{
13861368
"title": "GLTF Serializer KHR draco mesh compression",
13871369
"playgroundId": "#F8BF8N#3",
13881370
"excludeFromAutomaticTesting": true,
1389-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
1371+
"reason": "Draco loader passes 'utf8' label; BN TextDecoder only accepts 'utf-8' (WHATWG label normalization not implemented)",
13901372
"referenceImage": "glTFSerializerKhrDracoMeshCompression.png"
13911373
},
13921374
{
@@ -1399,63 +1381,57 @@
13991381
{
14001382
"title": "GLTF Serializer KHR gpu instancing",
14011383
"playgroundId": "#1Q2BWN#10",
1402-
"excludeFromAutomaticTesting": true,
1403-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
1384+
"excludedGraphicsApis": ["OpenGL"],
1385+
"reason": "Pixel diff 3.4% on OpenGL backend (Linux JSC); passes on D3D11.",
14041386
"referenceImage": "glTFSerializerKhrGpuInstancing.png"
14051387
},
14061388
{
14071389
"title": "GLTF Serializer KHR punctual light, left-handed",
14081390
"playgroundId": "#FLXW8B#27",
14091391
"replace": "//options//, roundtrip = true; useRightHandedSystem = false;",
1410-
"excludeFromAutomaticTesting": true,
1411-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
14121392
"referenceImage": "glTFSerializerKHRPunctualLightLH.png"
14131393
},
14141394
{
14151395
"title": "GLTF Serializer KHR punctual light, right-handed",
14161396
"playgroundId": "#FLXW8B#27",
14171397
"replace": "//options//, roundtrip = true; useRightHandedSystem = true;",
1418-
"excludeFromAutomaticTesting": true,
1419-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
14201398
"referenceImage": "glTFSerializerKHRPunctualLightRH.png"
14211399
},
14221400
{
14231401
"title": "GLTF Serializer Camera, left-handed",
14241402
"playgroundId": "#O0M0J9#25",
1403+
"excludedGraphicsApis": ["OpenGL"],
1404+
"reason": "Camera roundtrip diverges on OpenGL backend (Linux JSC), 21% pixel diff; passes on D3D11.",
14251405
"replace": "//options//, roundtripCount = 1; useRightHandedSystem = false;",
1426-
"excludeFromAutomaticTesting": true,
1427-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
14281406
"referenceImage": "glTFSerializerCameraLeftHand.png"
14291407
},
14301408
{
14311409
"title": "GLTF Serializer Camera, right-handed",
14321410
"playgroundId": "#O0M0J9#25",
1411+
"excludedGraphicsApis": ["OpenGL"],
1412+
"reason": "Camera roundtrip diverges on OpenGL backend; passes on D3D11.",
14331413
"replace": "//options//, roundtripCount = 1; useRightHandedSystem = true;",
1434-
"excludeFromAutomaticTesting": true,
1435-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
14361414
"referenceImage": "glTFSerializerCameraRightHand.png"
14371415
},
14381416
{
14391417
"title": "GLTF Serializer Camera, left-handed, round trip twice",
14401418
"playgroundId": "#O0M0J9#25",
1419+
"excludedGraphicsApis": ["OpenGL"],
1420+
"reason": "Camera roundtrip diverges on OpenGL backend; passes on D3D11.",
14411421
"replace": "//options//, roundtripCount = 2; useRightHandedSystem = false;",
1442-
"excludeFromAutomaticTesting": true,
1443-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
14441422
"referenceImage": "glTFSerializerCameraLeftHand.png"
14451423
},
14461424
{
14471425
"title": "GLTF Serializer Camera, right-handed, round trip twice",
14481426
"playgroundId": "#O0M0J9#25",
1427+
"excludedGraphicsApis": ["OpenGL"],
1428+
"reason": "Camera roundtrip diverges on OpenGL backend; passes on D3D11.",
14491429
"replace": "//options//, roundtripCount = 2; useRightHandedSystem = true;",
1450-
"excludeFromAutomaticTesting": true,
1451-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
14521430
"referenceImage": "glTFSerializerCameraRightHand.png"
14531431
},
14541432
{
14551433
"title": "GLTF Serializer Rotation conversion, left-handed",
14561434
"playgroundId": "#UK7FLI#1",
1457-
"excludeFromAutomaticTesting": true,
1458-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
14591435
"referenceImage": "glTFSerializerRotationConversionLH.png"
14601436
},
14611437
{
@@ -1793,31 +1769,27 @@
17931769
"title": "OBJ Stanford Bunny normals (round trip, LH)",
17941770
"playgroundId": "#26R8NS#6",
17951771
"replace": "//options//, roundTrip = true;",
1796-
"excludeFromAutomaticTesting": true,
1797-
"reason": "File API not available in Babylon Native JS runtime (ReferenceError)",
17981772
"referenceImage": "objStanfordBunnyNormalsRoundTripLH.png"
17991773
},
18001774
{
18011775
"title": "OBJ Stanford Bunny normals (round trip, RH)",
18021776
"playgroundId": "#26R8NS#6",
18031777
"replace": "//options//, roundTrip = true; useRightHandedSystem = true;",
1804-
"excludeFromAutomaticTesting": true,
1805-
"reason": "File API not available in Babylon Native JS runtime (ReferenceError)",
18061778
"referenceImage": "objStanfordBunnyNormalsRoundTripRH.png"
18071779
},
18081780
{
18091781
"title": "glTF to OBJ (LH)",
18101782
"playgroundId": "#HYZWGK#3",
18111783
"excludeFromAutomaticTesting": true,
1812-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
1784+
"reason": "Hangs on Win32 Chakra D3D11 - glTF to OBJ round trip",
18131785
"referenceImage": "gltfToObjLH.png"
18141786
},
18151787
{
18161788
"title": "glTF to OBJ (RH)",
18171789
"playgroundId": "#HYZWGK#3",
18181790
"replace": "//options//, useRightHandedSystem = true;",
18191791
"excludeFromAutomaticTesting": true,
1820-
"reason": "Pixel comparison fails (more than 20% pixels differ)",
1792+
"reason": "Hangs on Win32 Chakra D3D11 - glTF to OBJ round trip",
18211793
"referenceImage": "gltfToObjRH.png"
18221794
},
18231795
{

Apps/Playground/Shared/AppContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <Babylon/Polyfills/Blob.h>
2121
#include <Babylon/Polyfills/Canvas.h>
2222
#include <Babylon/Polyfills/Console.h>
23+
#include <Babylon/Polyfills/File.h>
2324
#include <Babylon/Polyfills/Performance.h>
2425
#include <Babylon/Polyfills/TextDecoder.h>
2526
#include <Babylon/Polyfills/Window.h>
@@ -156,6 +157,7 @@ AppContext::AppContext(
156157
}
157158

158159
Babylon::Polyfills::Blob::Initialize(env);
160+
Babylon::Polyfills::File::Initialize(env);
159161

160162
Babylon::Polyfills::Console::Initialize(env, [env, debugLog](const char* message, Babylon::Polyfills::Console::LogLevel logLevel) {
161163
std::ostringstream ss{};

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ FetchContent_Declare(ios-cmake
5454
EXCLUDE_FROM_ALL)
5555
FetchContent_Declare(JsRuntimeHost
5656
GIT_REPOSITORY https://github.com/BabylonJS/JsRuntimeHost.git
57-
GIT_TAG 1e9b17e4544862270420f0e192c5dfe56fe768d2)
57+
GIT_TAG 5449381d5ccad83fae720a2a934a23aa96c907a7)
5858
FetchContent_Declare(libwebp
5959
GIT_REPOSITORY https://github.com/webmproject/libwebp.git
6060
GIT_TAG 57e324e2eb99be46df46d77b65705e34a7ae616c

0 commit comments

Comments
 (0)