two issue:
1) click on add an instance block and it never ends
2) click on "+" to right of "Clear" and system "hangs"
Seems the "add an instance" has an implied "and wait"
Thanks to GP workshop participant who found this issue.
"add an instance" issue
Moderator: MSandro
"add an instance" issue
- Attachments
-
- addInstanceBug.gpp
- (5.36 KiB) Downloaded 289 times
Re: "add an instance" issue
Yes, you're exactly right. The current implementation waits for the initialize script to finish before proceeding. Thus, if the initialize script has a forever loop, it blocks everything. Since broadcasts normally spawn a new task (even "broadcast and wait" does; it just waits for the task(s) to finish), it's perfectly reasonable to expect this to work. We saw a similar problem at the workshop where someone called the "ask" block (which waits for user input) in an initialization script. (Maybe you saw that, too.)
I'm thinking of replacing the current confusing mechanism with a new hat block, "when instantiated," that does run in its own task when a new instance is created. Such a script could do initialization, start a "forever" loop, wait for user input -- whatever -- because the caller would proceed without waiting for the script to finish. That would do the expected thing with the given project.
For situations that require high performance initialization (e.g. the Pixel extension, which creates new instances of the Pixel helper class for every pixel in an image, potentially hundreds of thousands of them), one can use an "initialize" method added with the button in the "My Blocks" palette. Users of that feature need to understand that the initialize method is called synchronously and thus should not block or loop indefinitely. However, this feature would only be available in developer mode.
I'm thinking of replacing the current confusing mechanism with a new hat block, "when instantiated," that does run in its own task when a new instance is created. Such a script could do initialization, start a "forever" loop, wait for user input -- whatever -- because the caller would proceed without waiting for the script to finish. That would do the expected thing with the given project.
For situations that require high performance initialization (e.g. the Pixel extension, which creates new instances of the Pixel helper class for every pixel in an image, potentially hundreds of thousands of them), one can use an "initialize" method added with the button in the "My Blocks" palette. Users of that feature need to understand that the initialize method is called synchronously and thus should not block or loop indefinitely. However, this feature would only be available in developer mode.