mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
offload mpv callback registration to background thread to avoid UI blocking (#4038)
Instantiating `MPV(MPVBase)` triggers multiple synchronous `command()` calls to the mpv process during callback registration. These calls block the main thread and degrade startup performance. This change defers registration via `taskman.run_in_background`.
This commit is contained in:
parent
f29bcb743b
commit
7a8b4a193f
2 changed files with 3 additions and 2 deletions
|
@ -230,7 +230,7 @@ KolbyML <https://github.com/KolbyML>
|
||||||
Adnane Taghi <dev@soleuniverse.me>
|
Adnane Taghi <dev@soleuniverse.me>
|
||||||
Spiritual Father <https://github.com/spiritualfather>
|
Spiritual Father <https://github.com/spiritualfather>
|
||||||
Emmanuel Ferdman <https://github.com/emmanuel-ferdman>
|
Emmanuel Ferdman <https://github.com/emmanuel-ferdman>
|
||||||
|
Marvin Kopf <marvinkopf@outlook.com>
|
||||||
********************
|
********************
|
||||||
|
|
||||||
The text of the 3 clause BSD license follows:
|
The text of the 3 clause BSD license follows:
|
||||||
|
|
|
@ -41,6 +41,7 @@ import time
|
||||||
from queue import Empty, Full, Queue
|
from queue import Empty, Full, Queue
|
||||||
from shutil import which
|
from shutil import which
|
||||||
|
|
||||||
|
import aqt
|
||||||
from anki.utils import is_mac, is_win
|
from anki.utils import is_mac, is_win
|
||||||
|
|
||||||
|
|
||||||
|
@ -444,7 +445,7 @@ class MPV(MPVBase):
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self._register_callbacks()
|
aqt.mw.taskman.run_in_background(self._register_callbacks, None)
|
||||||
|
|
||||||
def _register_callbacks(self):
|
def _register_callbacks(self):
|
||||||
self._callbacks = {}
|
self._callbacks = {}
|
||||||
|
|
Loading…
Reference in a new issue