Use BabylonNative WindowT type#708
Draft
CedricGuillemet wants to merge 9 commits intoBabylonJS:masterfrom
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the React Native Babylon Native interop to pass a platform-specific graphics “window” handle (Babylon::Graphics::WindowT) into the shared graphics configuration, aligning iOS to pass the Metal layer instead of the MTKView.
Changes:
- Change
BabylonNative::UpdateViewdeclaration to takeBabylon::Graphics::WindowTinstead ofWindowType. - Update shared
ReactNativeModule::UpdateViewto store the passedWindowTdirectly (removing the iOS-onlywindow.layerconversion). - Update iOS interop to call
UpdateViewwithmtkView.layer.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Modules/@babylonjs/react-native/shared/BabylonNative.h | Changes the UpdateView API to accept Babylon::Graphics::WindowT. |
| Modules/@babylonjs/react-native/shared/BabylonNative.cpp | Updates internal UpdateView to store the window handle directly, removing iOS conditional logic. |
| Modules/@babylonjs/react-native/ios/BabylonNativeInterop.mm | Passes mtkView.layer into UpdateView on iOS. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
bghgary
approved these changes
Mar 18, 2026
wstring_convert<codecvt_utf8_utf16> is deprecated in C++17 and the BabylonNative cmakeextensions build helper adds -Werror to all Clang targets, turning this deprecation into a hard build error on Xcode 26+ / Clang 20+. Add -Wno-deprecated-declarations via add_compile_options for Clang/ AppleClang builds so the project compiles cleanly while all other -Werror checks remain enforced. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- postinstall.js: add BABYLON_USE_SYSTEM_CMAKE=1 env variable that bypasses the npm-bundled cmake-runtime package and uses whatever cmake is found on PATH (Homebrew, system install, etc.) - README: document the new BABYLON_USE_SYSTEM_CMAKE variable in the iOS CMake configuration section - README: add BabylonReactNative 2.0.2 entry to the Platform Native Packages version table (requires Babylon.js 9.0.0, BabylonNative 887a044) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Include QuartzCore/CAMetalLayer.h explicitly so that CA::MetalLayer is declared when BabylonNative.h is compiled. MTKView.h alone does not guarantee the CA namespace is available in all build contexts (e.g. the CI runner with Xcode 26). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
<QuartzCore/CAMetalLayer.h> only defines an Objective-C @interface, not the C++ CA::MetalLayer class from Metal-cpp. BabylonNative.cpp is compiled as a pure C++ translation unit, so including that header does not make the CA:: namespace visible. Replace the include with a C++ forward declaration: namespace CA { class MetalLayer; } This is sufficient for the pointer type alias in the header. The full definition is provided by the Metal-cpp headers that BabylonNative itself brings in when the implementation files are compiled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mtkView.layer returns CALayer* (ObjC), but UpdateView expects CA::MetalLayer* (C++ Metal-cpp type). These are ABI-compatible since MTKView always uses CAMetalLayer as its backing layer, but in ObjC++ we must bridge explicitly: 1. Cast CALayer* -> CAMetalLayer* (safe ObjC downcast) 2. __bridge void* (ARC-safe ObjC -> C pointer) 3. reinterpret_cast<WindowTypeUpdate> (void* -> CA::MetalLayer*) Also import <QuartzCore/CAMetalLayer.h> to declare CAMetalLayer in the ObjC++ TU. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.