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

DRAFT add queue and thread for processing mRunnables asynchronously #618

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mihbor
Copy link

@mihbor mihbor commented Apr 3, 2024

I discovered some issues caused by long running service.js code. The problem seems to be the MDSManager is single-threaded. When one Minidapp's service.js is doing something for a long time, blocking the thread, messages aren't delivered to other minidapps and the MDS Hub stops functioning corretly as well. Here's what I observed happens when service.js is running for a long time:

  • the Minidapp frontend stops receiving new messages when polling
  • other minidapps stop receiving messages to the UI as well as into their service.js
  • if you uninstall the Minidapp, the hub says its uninstalled but the service.js operation keeps running
  • if you update the Minidapp, the hub says its updated but when you click on it, you get the old version
  • if service.js is doing the long operation during initialization, then when you install the app and then click it in the Hub, it doesn't work, because the url is missing the UID, because it's only assigned after service.js has been initialized
  • if service.js is doing the long operation during initialization, when minima starts, the Hub doesn't work at all because until that finishes

I can't see a simple fix for this. Ideally, I imagine each mRunnable should have its own queue of commands to process and a (small) pool of worker threads should be picking the mRunnables with non-empty queues and processing them asynchronously, while the MDSManager would only add new tasks to the queues.
A much simpler approach that fixes the worst issues of the hub itself not working correctly would be to have at least a single queue of pending tasks for all the mRunnables and one background thread to process them.

This PR is just a draft, a WIP, to show what the approach could be, to begin with. It's far from ideal but I tested it (on desktop) to fix the hub missbehaving at least, as a start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant