for loop bug

22 August 2017 14:12
Hy i had a really bad time trying to get my scene onloader loop over previously loade scenes and i had to use a while loop. My conclusion B4W doesn't support for loops.
So i started a new porject added a simple for loop and it failed to load.

in the broswers console if i type it directly it work :

for (i=0; i<9; i++) {

but if you add it to app.js it fails and B4W never loads.

I attach a simple app to illustrate the problem.

If it come from my setup let mee know. I'm using B4W 17-06 with B3D 2.8c
22 August 2017 14:22
I noticed there is a for loop in toon furniture so i tried to launch it from the project manager on my local copy of B4W… well it doesn't launch…
22 August 2017 14:37
What error are you getting in the browser console when you try to launch the Cartoon Interior project.
Other details help. What is your operating system and browser?
22 August 2017 14:42
no message in the console. Just the preloader that freezes. I'm on Fedora26_64 bit using firefox 55.
I don't have chrome on this machine.
EDIT : Chromium fails to open cartoon interior to.
23 August 2017 07:08
You may need to do some investigation into Fedora's support of WebGL in browsers. I have no experience running Fedora so I don't think I can be of much help there.
23 August 2017 11:17
Funny enough on this page
the app works on my machine…. In Firefox.

For support of webgl in fedora you have to go back in 2012 to find anything. The more recent post all being about firefox changing some GL parameter under the hood to avoid more crashes. I don't think that's it. And i'm running X11 not wayland.
And again it all works perfectly fine as long as they are no for loops in custom.js
23 August 2017 16:28
for (i=0; i<9; i++) {
This code should produce the "Uncaught ReferenceError: i is not defined" console message when pasted directly in one of the engine's modules. That's because there should be the line "use strict;" at the top of a module, that enables a special strict mode, in which JavaScript code should be executed. In short, this mode prevents from writing insecure or bad code and helps debugging. One of the limitations of the strict mode is that you cannot use undeclared variables. So, you just need to declare "i" via "var":
for (var i=0; i<9; i++) {

The browser console doesn't force strict mode, that's why you don't get any errors from simply typing in it.
Blend4Web Team
23 August 2017 18:26
Oh My GOD !!
Thank you so much! I am glad that's not a bug ! But i just couldn't figure out what else !
I have never heard of that var = i syntax and i would never have thought of it… I will try to remember that!
B4W is a bit tricky.

How could i get more debug info from B4W because it just crashed and that was it.
24 August 2017 10:40
How could i get more debug info from B4W because it just crashed and that was it.
the browser console is the first thing to check, it should show errors in a case of a crash as well as other log messages
Blend4Web Team
24 August 2017 17:13
Not in my case. It just silently failed and look at me with disdain…
Please register or log in to leave a reply.