Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main event loop should pause during blocking operations in lua #461

Closed
mhetrick opened this issue Jul 7, 2018 · 6 comments
Closed

main event loop should pause during blocking operations in lua #461

mhetrick opened this issue Jul 7, 2018 · 6 comments
Labels

Comments

@mhetrick
Copy link

@mhetrick mhetrick commented Jul 7, 2018

I'm experiencing weird behavior when performing a USB sync with the "wormhole" script open. As soon as the sync completes, there is a massive explosion of sound, as though the engine is attempting to catch up with a large queue of Lua messages. This slows norns down to a crawl. I can still navigate to SLEEP, but it takes many button presses until the machine responds.

@catfact catfact added lua matron labels Jul 7, 2018
@catfact
Copy link
Collaborator

@catfact catfact commented Jul 7, 2018

renamed issue. more generally, the problem is that handling an event in lua blocks the main event loop.

unfortunately, i don't see a trivial solution for this.

  • we can add a mechanism for lua to temporarily stop new events from being posted, but of course we will miss things.

  • we could investigate doing long blocking operations like usb sync in a coroutine.

@catfact catfact changed the title Audio callback and/or Lua clocks should pause during USB sync main event loop should pause during blocking operations in lua Jul 7, 2018
@tehn
Copy link
Member

@tehn tehn commented Jul 7, 2018

other processes that block:

  • UPGRADE
  • WIFI operations (though generally shorter)

perhaps scripts/engines should just be shut down before any of these operations. this would require implementing engine.shutdown()

@catfact catfact self-assigned this Jul 8, 2018
@catfact
Copy link
Collaborator

@catfact catfact commented Jul 8, 2018

i don't think it's sufficient to stop scripts and engines. unhandled items in the main event queue need to be avoided entirely. (consider joystick, CC or midi clock input that can produce many events quickly / continuously.) i can make the necessary changes to events and weaver.

@tehn
Copy link
Member

@tehn tehn commented Jul 8, 2018

i meant running cleanup() which should null out any callbacks to norns.none

this seems sufficient to have the event loop continue but do nothing? or are you suggesting we'd overflow the event queue?

@catfact
Copy link
Collaborator

@catfact catfact commented Jul 9, 2018

are you suggesting we'd overflow the event queue?

Yes that's what I mean. It's not a huge or mysterious problem but it needs attention

@catfact catfact removed their assignment Nov 1, 2018
@tehn
Copy link
Member

@tehn tehn commented Jun 25, 2019

likely solution: #779

@tehn tehn closed this Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants