py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

`py5_tools.get_screenshot()` seems to make the Sketch hang when called from the event function `key_pressed()` #99

Closed hx2A closed 2 years ago

hx2A commented 2 years ago

get_screenshot() adds a hook that gets called after the next iteration of draw(). It won't get the screenshot before then. The get_screenshot() method will wait for its screenshot, but somehow this prevents the animation thread from running. The Sketch gets caught in a Catch 22.

If this can't be fixed it should at least detect it and throw an error, alerting the user that the function is being used incorrectly.

hx2A commented 2 years ago

Nothing in py5_tools.hooks.frame_hooks.py should block when called from a py5 user method (draw(), setup(), etc.) The get_screenshot() function always blocks and blocking is optional for the others. The others should work fine if block=False.

hx2A commented 2 years ago

The solution was to check the callstack and make sure bridge.py is not in the stack.