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

Avoid race condition playing local content #172

Merged
merged 15 commits into from
Nov 23, 2021
Merged

Avoid race condition playing local content #172

merged 15 commits into from
Nov 23, 2021

Conversation

lulol
Copy link
Contributor

@lulol lulol commented Oct 13, 2021

# https://github.com/jaseg/python-mpv#pygobject-embedding
# Must be created >after< the widget is shown, else property 'window' will be None

Wait for window to get ready before retrieving properties and playing content to avoid failures with local content.

This is to minimize the chance of an issue first [reported](#65 (comment)) by @dilutedh2o for huge lists.

Triggering multiple searches before the channels FlowBox rendering is completed may result in Hypnotix being unresponsive for several minutes. Also CTRL-C doesn't work. Have not been able to trace the root cause. May be related to network failures of pending channel logo downloads flooding the home router dropping traffic?
Use Gtk.FlowBox.set_filter_func() instead of destroying and recreating Gtk.FlowBox childs.
# https://github.com/jaseg/python-mpv#pygobject-embedding
# Must be created >after< the widget is shown, else property 'window' will be None

Wait for window to get ready before retrieving properties and playing content to avoid it to fail with local content.
@lulol
Copy link
Contributor Author

lulol commented Oct 13, 2021

*Urgh* Sorry for the mess. Hope you squash all these commits. :(

@superolmo
Copy link
Contributor

I like the idea, but that is a dangerous loop that could never end. Maybe adding a simple counter up to a value in seconds will guarantee that the wait is no longer than N seconds. Also, just throwing ideas here, it would be nice to show that the process is waiting in the loop by maybe temporarily change the box color around the MPV window or some other visual indications.

@lulol
Copy link
Contributor Author

lulol commented Nov 5, 2021

You are right. Added a Gtk.events_pending() to handle main loop events while waiting, that I think that may be a better approach than a fixed timeout, but my Gtk knowledge is *very* limited.

Already had tried calling the main gtk loop after the sleep with Gtk.main_iteration_do(False) but that didn't seem to do anything.

The UI already shows a spinner in the widget window before mpv tries to start displaying the content before the window is created. But I guess that you always can press the back button and try again like sometimes is needed now without this patch.

@clefebvre clefebvre merged commit 8efcce9 into linuxmint:master Nov 23, 2021
@lulol lulol deleted the lulol-race_patch branch November 23, 2021 12:41
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.

None yet

3 participants