Hello BJS community,
While using BJS v5.0.0 rc4 or v5.0.0.
We have a scene with a static environment/reflection texture, with various meshes using PBR materials, dynamic shadows with the use of shadow depth wrappers. We have objects/nodes being hidden and shown at different times. At some point in that flow we hit the following JS error in our browser console ONLY when we have a browser with a iOS user agent,
TypeError: null is not an object (evaluating 's.USESPHERICALFROMREFLECTIONMAP')
Because the JS is bundled and minified, it’s say it’s at file/line bundle.js.11:3259239, and I can’t really make any sense of it.
This issue doesn’t present itself when we run in a desktop browser that isn’t simulating an iOS user agent. Also doesn’t present itself if we turn shadows off completely.
This issue does present itself on iOS device with Safari and Chrome browsers too.
Can you please suggest how I might be able to debug or fix this issue further?
Ping @sebavan - does this relate to the known iOS issue?
I do not think so here, it looks like a defines object on PBR would be null which does not make any sense.
What is the callstack of your error ?
I was having trouble getting the callstack earlier. But I’ve managed to get it now.
Uncaught TypeError: Cannot read properties of null (reading 'USESPHERICALFROMREFLECTIONMAP')
at t.bind (bundle.js:26:3107156)
at t.bindForSubMesh (bundle.js:26:2565975)
at e._renderSubMeshForShadowMap (bundle.js:26:2729966)
at e._renderForShadowMap (bundle.js:26:2727866)
at e.render (bundle.js:26:4047441)
at e.render (bundle.js:26:853357)
at t.renderToTarget (bundle.js:26:1445595)
at t._render (bundle.js:26:1441364)
at t.render (bundle.js:26:1439219)
at t._renderForCamera (bundle.js:26:273773)
Please see my previous post for a call stack. We’ve found if we don’t use a ShadowDepthWrapper on our meshes this issue disappears.
It’s quite impossible understanding a minified stacktrace, especially when bundled by you. Would it be possible to add sourcemaps, or use the unminified source?
Having said that - will you be able to provide a (non) working demo? something devs with iphone can make sense of?
Also it looks like you are using a PBR material in a shadowDepthWrapper ???
Yes, we are applying a shadow depth wrapper to a NodeMaterial which has a “PBRMetallicRoughness” block in it.
Similar to the approach shown in the example PG from the documentation: https://playground.babylonjs.com/#PNQRY1#80
Is that a problem? I found the function to make a ShadowDepthWrapper odd in that you supply the material to the function and you also have to apply the function result to the material that was passed into the function as a parameter. It makes me question if I’m using it correctly.
Additionally the NodeMaterial shader I’m using also has a frame used for providing semi/fading transparent shadows via a BayerDither function which ultimately feeds into a “Discard” block.
Once I can distill the problem down further I would like to provide a PG demo of the issue. I will attempt to get a build setup with sourcemaps or unminified source to get a better handle on the issue and I’ll report back.
Yup it makes sense, would be great to have your repro indeed as it sounds impossible to troubleshoot without it.
A side question while you prepare the repro - did you make due you import all required blocks when building? Could it be that you are missing the block that is responsible for that part?
Hello @kizjig just checking in, are you still having issues? If so, can you provide us with the repro?