[SOLVED] UI bug when changing scenes

We started testing the UI stuff, and our multi-scene game runs into trouble when re-loading a scene.
We get this error in the console, after which objects are created but none of them will have initialize called (presumably because of this UI related excpetion).

A lot of our code relies on initialize so for now it looks like we can’t use the UI, unless we’re doing somethign wrong? The UI we’re using is a single textbox.

The flow that causes it:

  • start in menu scene (with no UI)
  • open scene with UI textbox
  • go back to menu
  • open scene with UI textbox again
  • crash

launch.js:6281 loadScene (editor.method error)
launch.js:6282 TypeError: Cannot read property 'lock' of null
    at VertexIterator (playcanvas-stable.dbg.js:3284)
    at TextElement._updateMesh (playcanvas-stable.dbg.js:28050)
    at TextElement._updateText (playcanvas-stable.dbg.js:28011)
    at TextElement.set (playcanvas-stable.dbg.js:28359)
    at TextElement._onFontLoad (playcanvas-stable.dbg.js:28218)
    at Asset.fire (playcanvas-stable.dbg.js:608)
    at Array.<anonymous> (playcanvas-stable.dbg.js:30781)
    at ResourceLoader.<anonymous> (playcanvas-stable.dbg.js:28694)
    at playcanvas-stable.dbg.js:29865
    at ResourceLoader.load (playcanvas-stable.dbg.js:28679)

uhm a link to the project could help :wink:

It would be great if you could provide a simple test case that reproduces the issue.


I set up a test-project but couldn’t reproduce the error, so I started digging deeper in our main project (which I can’t really share).
Turns out it was an unholy mix of disabling preload, and forcing load/unload between scenes which works differently for fonts than for other assets it seems.

It works now, and the bug is not in the UI but our code. Thanks!

1 Like