iOS/JSC: getUserMedia camera VideoTexture never renders — NativeVideo::SetSrcObject rejects MediaStream (InstanceOf fails across napi/JSC)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- cpp, ios, javascript
- Domain
- computer-graphics, mobile-dev
Research direction
Start with Apps/Playground on iOS using the cameraTexture path in experience.js, then inspect NativeVideo::SetSrcObject in Plugins/NativeCamera/Source/NativeVideo.cpp and trace the failing InstanceOf check on JavaScriptCore. Done means the genuine getUserMedia MediaStream is accepted, the playing event occurs, CreateFromStreamAsync resolves, and the camera VideoTexture renders on iOS.
Written by the indexing model from the issue text.
Description
Summary
On iOS (JavaScriptCore), NativeVideo::SetSrcObject rejects the MediaStream returned by navigator.mediaDevices.getUserMedia, so VideoTexture.CreateFromStreamAsync never renders the camera feed. Camera capture works (AVCaptureSession runs, frames flow), but no texture ever updates.
Environment
- Babylon Native
master@64f545de; Babylon.js9.9.1(UMDbabylon.max.js) - iOS 26.5, iPhone 15 Pro Max (device), Xcode 26
- Repro:
Apps/PlaygroundiOS with thecameraTexturepath inexperience.jsenabled
Root cause
Plugins/NativeCamera/Source/NativeVideo.cpp, SetSrcObject:
if (value.IsNull() || value.IsUndefined() ||
!value.As<Napi::Object>().InstanceOf(MediaStream::GetConstructor(env)))
{
// reject: m_streamObject cleared, m_isReady = false
return;
}
getUserMedia creates the stream via MediaStream::GetConstructor(env).New({}), and SetSrcObject checks InstanceOf(MediaStream::GetConstructor(env)) against the same cached constructor — yet InstanceOf returns false across the napi/JavaScriptCore boundary for the genuine MediaStream object.
On-device trace (instrumented):
SetSrcObject called null=0 obj=1 instanceOfMediaStream=0 <- object is a MediaStream, InstanceOf fails
Because the stream is rejected, readyState stays 0, so Babylon.js's VideoTexture.CreateFromStreamAsync never gets the "playing" event (its NativeVideo::Play only fires "playing" when a stream is set), the returned Promise never resolves, the VideoTexture is never constructed, and engine.updateVideoTexture is never called.
Impact
getUserMedia + VideoTexture.CreateFromStreamAsync (camera-to-texture) is completely broken on the JSC/iOS backend.
Suggested fix
Either investigate why Napi::Value::InstanceOf fails for ObjectWrap constructors on the JSC engine, or identify the MediaStream more robustly. A pragmatic fix is to duck-type on the presence of getVideoTracks:
const bool looksLikeMediaStream =
value.IsObject() && value.As<Napi::Object>().Get("getVideoTracks").IsFunction();
if (value.IsNull() || value.IsUndefined() || !looksLikeMediaStream) { /* reject */ }
Happy to open a PR.
- Dominant language
- C++
- Stars
- 931
- Forks
- 169
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 66
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from BabylonJS/BabylonNative
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
BabylonJS/BabylonNative#2138 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BabylonJS/BabylonNative#2042 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
BabylonJS/BabylonNative#2052 ·
Maintainers usually reply within 1 day
-
testing
Difficulty 4/5 3-5 days Newbie friendliness 45/100
BabylonJS/BabylonNative#2136 ·
Maintainers usually reply within 1 day
-
Support useNDCHalfZRange (half-range NDC depth) so Babylon.js half-range depth visual tests can runPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
BabylonJS/BabylonNative#2134 ·
Maintainers usually reply within 1 day
All issues in BabylonJS/BabylonNative
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itselfPossibly taken @fedonman claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
task
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
SparseLinearAlgebra/spla#316 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 3 days