Bug on Highlight layer: Cannot create property '_needNormals' on string '#define NUM_BONE_INFLUENCERS 0 #define HIGHLIGHT'

Hi,

Trying to use a highlight layer in any way gives me this error and crashes the scene when I try to add a highlight layer.

I tried using the basic Highlight Layer example from the babylonjs examples, within the context of my scene creation, and I get this error.
I copied the code directly from the example and pasted it in right after my scene creation.

It must be something within my scene setup? I dont think I am doing anything egregious.
looking at the code, defines is expected to be an object in isReadyForSubMesh, but it is a string.
Any ideas how would this happen?

Heres the stack trace:

babylon.js:1 Uncaught TypeError: Cannot create property ‘_needNormals’ on string ‘#define NUM_BONE_INFLUENCERS 0
#define HIGHLIGHT’
at t.isReadyForSubMesh (babylon.js:1:1678948)
at t.isReady (babylon.js:1:1096734)
at t.isReady (babylon.js:1:1895752)
at l.pointerMovePredicate.l.pointerMovePredicate (babylon.js:1:469149)
at mn._internalPick (babylon.js:1:1018598)
at mn.pick (babylon.js:1:1020158)
at e._onPointerMove (babylon.js:1:469371)
at c.eval [as callback] (babylon.js:1:472871)
at e.notifyObservers (babylon.js:1:63601)
at e._onInputChanged (babylon.js:1:457271)

  1. you must ensure that your engine was created with stencil on:
var engine = new BABYLON.Engine(canvas, true, { stencil: true });

  1. After the point 1, try to insert into your previously working code
var hl = new BABYLON.HighlightLayer("hl1", scene);

and then check if it is successfully created

  1. If point 2 is OK, try to add some mesh to highligh layer.

Which Babylon.js version are you using? Can you test with the latest one?

I think it could be a bug we fixed in the previous months…

Oops should have included that- its running on 5.27.1.
It was having same problem on 5.0.0. just updated and still there.

I think it may have something to do with scene disposing?
It works untiI I dispose the scene and reload.

Hm I think I figured out what the issue was- I think I fudged some async code and it actually disposes and starts a new scene before the previous was done rendering. I’ll do some more investigating.

Spoke too soon… Im kind of clueless again

to clarify, the stencil option did not help

Are you able to provide a repro in the Playground? It’s going to be difficult to find the problem without it.

Maybe it’s the same bug than the one fixed here:

Try to test your project with an updated Babylon.js package when the PR is merged.

Hello @aprowe just checking in if you still have questions