Code is not executed in Processing, but in p5.js Web Editor

You don’t have to believe me! Just check w/ your own eyes what are the functions registered to work w/ preload() callback by default straight from p5js’ source code: :eyes:

There are only 9 p5js loading functions which cause preload() to await their full completion by default.

Anything else gotta precall registerPreloadMethod() so preload() knows how to await for them as well.

Just placing some unregistered stuff inside callback preload() won’t magically make it work!

The p5.js web editor got lotsa other stuff running behind-the-scene.

It’s more or less expected for the p5js library and its callbacks to run much later on such environments.

In order for the sketch to work the callback getDevices() must run before p5js setup() is called back.

Otherwise the array deviceList[] will still be empty when the code reaches setup().

Leaving the sketch on a state which depends on how fast a callback is invoked before the other is unacceptable IMO. :no_good_man:

Such code is clearly buggy! :bug: