Large Blockly project with more than 7K blocks

161 views
Skip to first unread message

jimmy joseph

unread,
Nov 18, 2022, 9:49:22 AM11/18/22
to Blockly
I have been experimenting with Blockly and found that randomly adding blocks more than 5k or so significantly slows down and freezes the UI. I totally understand that, in reality we might not need more than 5K blocks in a single blockly project file. Nevertheless, I would love to hear from others here - are there any techniques to prevent the UI from freezing after adding large number of blocks?  How can we handle and deal with large blockly project files (let's keep splitting into multiple files away for time being). 

Neil Fraser

unread,
Nov 18, 2022, 10:01:31 AM11/18/22
to blo...@googlegroups.com
Can you recreate steps using the playground?
Performance is important to us, but we aren't seeing UI freezes at 5k blocks.

There are currently too many unknowns around this issue.  Maybe they are using Angular.  Maybe they have 640kb of memory.  Let's get a repeatable test case nailed down.

Am Fr., 18. Nov. 2022 um 15:49 Uhr schrieb jimmy joseph <jim...@gmail.com>:
I have been experimenting with Blockly and found that randomly adding blocks more than 5k or so significantly slows down and freezes the UI. I totally understand that, in reality we might not need more than 5K blocks in a single blockly project file. Nevertheless, I would love to hear from others here - are there any techniques to prevent the UI from freezing after adding large number of blocks?  How can we handle and deal with large blockly project files (let's keep splitting into multiple files away for time being). 

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/949542cb-fece-48d7-801f-c4286efb9b7an%40googlegroups.com.


--
Neil Fraser, Switzerland
https://neil.fraser.name

jimmy

unread,
Nov 18, 2022, 10:33:41 AM11/18/22
to blo...@googlegroups.com
Here is the blocks xml file saved from playground.


Thanks
_____________________
Jimmy


bloxks.zip

Neil Fraser

unread,
Nov 18, 2022, 11:07:03 AM11/18/22
to blo...@googlegroups.com
Thanks for that.  First finding is that it's lightning quick in Firefox.  No issues there.  Likewise, Safari is smooth.

Google Chrome on the other hand is problematic.  First it's very choppy (but usable).  An examination of the console shows that most of the CPU is going to 'rendering', not Blockly's JavaScript.  But leave the page alone for a few minutes, and it becomes utterly unusable.  So in addition to everything else, there's a major memory leak happening.  This is going to be fun.

jimmy

unread,
Nov 18, 2022, 11:27:57 AM11/18/22
to blo...@googlegroups.com
Thanks a ton Neil for responding.

Yes, we primarily use Chrome or embed blockly via MS Edge webview in our windows app. Everything works perfectly - except it cannot handle blocks  > 5K. Yes it can; but the experience is not so pleasant unfortunately. 


Thanks
_____________________
Jimmy


Ewald Ramp

unread,
Nov 18, 2022, 3:32:57 PM11/18/22
to Blockly
We had some very large blockly configurations that caused us to run into a similar problem (in a ReactJs context), while I have no idea how many blocks in total were in there, we have one configuration, when exported to JSON, that was over 60MB.

I can confirm that the rendering is the problem. Loading that many blocks in a virtual workspace has little to no impact.
What we ended up doing was keep 2 workspaces around, one rendered, one virtual. 
The virtual workspace would have the complete document.
On the rendered workspace, we added a change listener, whenever a block is collapsed, we remove all the children. When it is expanded again, we recreate the child blocks in from the non-rendered workspace. As long as you don't need to keep many blocks open at the same time, it works.  But you'll have to add a lot of extra logic to replicate normal behavior. Copying blocks for instance needs to copy the virtual copy of the block, not the one the user actually had selected. As otherwise you'd loose the collapsed children.

Obviously, it still is a problem when you need a lot of blocks open at the same time, but if not, it helps it be manageable.

Note, recently we have refactored our use of blockly, allowing us to break up the large blockly configurations in much smaller sets, which obviously mitigates the problem.

Hope that helps?

Ewald

jimmy

unread,
Nov 18, 2022, 5:06:58 PM11/18/22
to blo...@googlegroups.com
Thanks Ewald - yes splitting one program into multiple chunks definitely works. Nevertheless, it would be an awesome feature, if blocky could handle large set of blocks. 

Neil Fraser

unread,
Nov 18, 2022, 5:11:30 PM11/18/22
to blo...@googlegroups.com
The team here at Google are dying to know what your use cases are.  If it's private, feel free to email us off the list.

jimmy

unread,
Nov 18, 2022, 5:36:24 PM11/18/22
to blo...@googlegroups.com
Hi Neil, 

We use blocky to code pure python  for a rule engine. At present there are no python code that are larger than 1k blocks. And we could split large source file to multiple chunks - this issue is not a show stopper. 
We love blocky and wanted to see that it could handle large number of blocks. :-)

Christopher Allen

unread,
Nov 22, 2022, 2:00:13 PM11/22/22
to blo...@googlegroups.com
I have filed #6654 to track this issue.

Ewald Ramp

unread,
Nov 30, 2022, 3:31:00 PM11/30/22
to Blockly
Hi Neil,
I think David Welling, a colleague of mine, might have shared our use case in the past, though our usage definitely has grown since. 
We use Blockly probably well outside its original envisioned use.
We use it somewhat like a low/no code style, where we allow non-devs to define user interfaces, with various features like access permissions, data sourcing and viewport adaptation.
For this, we defined about 120 or so custom blocks, and we use a customized JavaScript generator to generate a JSON "metadata" file.
That metadata then is used to render a UI dynamically (in ReactJS on the web, and React Native on devices), it drives api access and payload validation, and even influences business logic/workflows run on the data.
All of this runs as a multi-tenant SaaS environment with multiple users per tenant, with tenant-specific customizations expressed in blockly as well. The biggest application has about 80 different screens defined that way. 
A screenshot might help envisioning it:
MetadataCreator.png

Hope that gives some idea of our use? 
Let me know if you want to hear more. 
We love Blockly, and while perhaps not originally designed for this, it really works for us.

Ewald
Reply all
Reply to author
Forward
0 new messages