Interesting: Here’s an updated version of my Fizz Buzz page that causes Bubble to blow up the call stack when the numeric list (being generated via a workflow loop) gets to about 600 items. [EDIT: whoops, forgot to share the link! It’s same as before…]:
https://list-shifter-dev-test.bubbleapps.io/version-test/fizz_buzz?debug_mode=true
In an attempt to speed the (Bubble version) of things up, I have simply:
- Removed the scalar numeric state (which was holding the current count of items) from Text Debug.
- Instead of incrementing that state, or incrementing the numeric list state on Text Debug, it simply forwards the new list of numbers (numberlist :plus item number) and the next number (number + 1), which are now simply workflow parameters.
- The numeric list on Text Debug (the “complete” list of numbers) is only updated when the numeric list is finished or when numberlist: count mod somevalue (set via “Input Print Every…”) is zero (that is, only update the list state every x items).
The thinking here being that (as I have long known) Set State is inefficient and Set State seems to take an inordinate amount of time to execute. So, let’s do that as little as possible.
To see this blow up the call stack, set Number of Iterations to 1000 and Print Every to 100 and watch the console (hit F12) and the page. You’ll see two things:
- The chunking of items (it’s only updating the numeric list state every 100 items) gets slower and slower the longer the list gets and
- After the sixth chunk (items up to 600), it blows up the call stack and halts (at least on my machine – your mileage may vary depending upon system and browser)
The error in question relates to a call to JSON.stringify(), which I guess is somehow involved in either setting states and/or passing Custom Event parameters.
Damn you, @adamhholmes for encouraging the exploration of interesting stuff. Note that this is just more and more an argument for avoiding the use of vanilla Bubble for even basic stuff. (You could conceivably blow up the call stack or run the browser out of memory by generating extremely large lists with Polyhedra [or Floppy, or List Shifter]), but those lists have to get very very large. (In the case of Polyhedra, you’ll note that I generated a list of 1 million numbers and things worked just fine.)
Also, it’s an argument for Bubble to revisit things like Set State and Custom Events. These are simply not implemented well, as far as I can tell. On the plus side, it seems that the plugin API’s “publishState()” method (while it has it’s own strangenesses and bugs) does not suffer from the same issues as the Set State action. (I have no explanation of why that’s the case as it is not my code.)
