Hi friends, my react app that uses babylon, which I last built a year ago, was working perfect a year ago. Now I have to update it. So I did npm install from the beginning and this is the problem:
Before when running the app, it would load the models normally, and I get in the console this
do you have some advice to solve this even as a patch, I mean , why is it referring to 4.2.2 when I am not referring to 4.2.2 anywhere? is that what is breaking it?
the code that loads the stuff has not been touched at all. I just needed to change some text in the info screen. Nothing else has been touched. And yet now the loading of the models is broken.
Do I have to somehow force the babylon version installed to be 4.2.0 like before? but I thought thats what my package.json is already doing
thank you @labris , yes that’s the first thing I did, I deleted npm cache, deleted those folders and did npm install from zero, and unfortunately I have this problem still there, all the time
i looked inside node-modules and its installing 4.2.2 for some reason, although it should install 4.2.0, I dont know if that’s the reason of the problem but that seems to be a difference
If I’m not mistaken, in your package.json you are specifying that you would like the most current version of Babylon.js 4.2.x, which happens to be 4.2.2. This allows authors to easily apply servicing updates (e.g., patch version changes for security fixes) without specifically requesting that patch version.
If you want to only use 4.2.0, remove the ^ prefix from the packages and run a clean install with npm ci.
oh I see, yes, getting rid of that symbol should force it to install 4.2.0 ok , and then I can do npm install after deleting node-modules, I will try it, thank you, I hope that’s whats causing the problem, the difference between 4.2.0 and 4.2.2, lets see
@jelster@labris it worked, I reinstalled all and now I have babylon 4.2.0. But unfortunately Im still getting the very same error I had before (as shown in the screenshot above). Strange really, 1 year ago it wasn’t happening
very strange, I got the package-lock.json from when the app was working and I did npm ci , and it installed etc, but I get the very same error that you see in the capture above. So maybe the problem is somewhere else? but where?
I see a bunch of
“WebGL: INVALID_VALUE: getProgramParamter: attempt to use a deleted object”
and then
Uncaught (in promise) Error: Unable to load from ./models/million3-hr/million3-hr.babylon: Scene has been disposed
at sceneLoader.js:754:1
at errorHandler (sceneLoader.js:673:1)
at dataCallback (sceneLoader.js:194:1)
at successCallback (sceneLoader.js:224:1)
at XMLHttpRequest.onReadyStateChange (fileTools.js:435:1)
but nothing has been changed in the code from a year ago and a year ago it compiled and worked all perfectly
its funny because I have the react build I created last year and it keeps on working perfectly in all browsers, this means that it’s not a browser issue.
And after doing npm ci with the package lock of last year one would think that it also would not be a library issue.
So then I don’t get where the issue is
any ideas about this? I would think that a babylon app that I last built a year ago, and whose code has not changed since then, should still build today, thank you for any suggestions
Have you tried adding any logging around the useEffect function, specifically around the bottom part where it calls scene.dispose to see what might be causing the scene to be disposed prematurely?
Another thing to look at is whether you’re getting a WebGL context lost event (are you tabbing away or causing the browser window to lose focus while developing?) and handling it if or as needed. IIRC, newer versions of BJS may handle it differently/better iirc.
@jelster I think that nothing of that would help. The code has not changed. It built successfully 1 year ago. The build created 1 year ago continues to run 100% well in all browsers today. The problem is something else which I cannot yet pinpoint
I get your code hasn’t changed, but what about React? Did the version update or change there?
What are your other base assumptions, and have you validated they align with your ground-truths? I know that when the impossible seems to be happening, it can help to re-examine these types of things. Sorry you’re having so much friction for what must feel like something so simple!
I’m not sure if this will fix your issue, but I noticed in your package.json you are including both the @babylonjs packages (that start with @) and the babylonjs packages that do not start with @. It’s my understanding that you should never mix them. Use all packages of one type or the other but not both.
@jelster thank you for your great advice and support.
React version maybe, but I am doing “npm ci” from package lock of when it was compiling well so that should ensure that everything, including React would stay the same as last year, right?
@owen, but what is the way to unify these? I cannot simply delete the ones that don’t have @ because they are libraries that the code uses, so what’s the fix?
Delete all occurences of BABYLON. in your source. Use global replace.
Delete all imports from the legacy packages. import whatever from 'babylonjs' (delete imports for the GUI and materials as well)
Read this: Auto-add missing imports on file save in VS Code ✨ - DEV Community
Or do it manually in each file (I would do it this way):