Anki wont open >> MPV TIMED OUT << (?)

My anki was working fine when I downloaded the latest version 2.1.40. It was still working, but it was starting slowly. And then, it just wouldn’t open. So I downloaded the previous version 2.1.35, but the problem continued.

So I looked and saw that I had to open anki-console.exe, so I did and nothing happened. This message came out, saying MPV TIMED OUT, RESTARTING.

I’ve tried to reinstall, restart the pc and nothing … Please someone help me


Meu anki estava funcionando bem, quando fiz o download da versão 2.1.40 mais recente. Ainda estava funcionando, mas estava começando devagar. E então, simplesmente não abria. Então baixei a versão anterior 2.1.35, mas o problema continuou.

Então eu procurei e vi que tinha que abrir o anki-console.exe, então eu fiz e nada aconteceu. Esta mensagem saiu, dizendo MPV TIMED OUT, RESTARTING.

Já tentei reinstalar, reiniciar o pc e nada … Por favor alguém me ajude

I’m not sure where’s the problem, but a quick workaround is to install Anki 2.1.35-alternate and either use this version or copy mplayer.exe from C:\Program Files (x86)\Anki to C:\Program Files\Anki and delete or rename mpv.exe.

2 Likes

About “mpv timed out, restarting”, maybe enabling the debug mode while starting mpv to see what requests were made will help to understand what happens and maybe something could be done about it.

To do it, it’ll be necessary to install Python 3.8 and run a script that will start mpv the same way as Anki does but with the debug mode enabled.

  1. Download and install Windows installer (64-bit) from https://www.python.org/downloads/release/python-387

    During the installation process, check the box that says “Add Python 3.8 to PATH”.

  2. Open the Windows Command Prompt (cmd.exe) and install an additional Python module with this command: python -m pip install pywin32

  3. Use Download ZIP to download this gist and unpack it somewhere. It contains “main.py” and “mpv.py” - https://gist.github.com/kelciour/25b2f82cee7a1944fd875e9c4a8d02d7

  4. Search for an app called “IDLE (Python 3.8 64-bit)” and open “main.py” with it.

  5. Run > Run Module.

  6. The script should stop working after a few seconds. In your case, it’ll keep running.and either press Ctrl+C or Shell > Interrup Execution. Then scroll up to the top and take a screenshot or maybe copy the full output and upload it on https://gofile.io/ or somewhere else.

3 Likes

Hey Kelciour,

thanks for the tip with replacing the mpv.exe with mplayer

Nevertheless I did run the debugging scripts you provided and found following results:

When running main.py the first time I get following errors:
Anki Version 2.1.46 x64

moved to github gist because it was to long:
https://gist.github.com/legeiger/7ef1c7bec410d521fd3607c1a6fa94fb

but when running the exact same command again mpv.exe runs just fine (second file)
https://gist.github.com/legeiger/7ef1c7bec410d521fd3607c1a6fa94fb

but when tring to open Anki now again it does not just give me the normal mpv.exe timed out error but something more:

mpv timed out, restarting
Traceback (most recent call last):
  File "threading.py", line 932, in _bootstrap_inner
  File "threading.py", line 870, in run
  File "aqt\mpv.py", line 234, in _reader
AttributeError: 'MpvManager' object has no attribute '_sock'


Maybe this can help you for now. Let my know if I can help you any more with debugging this problem.

I think mplayer works just better for now..

Thank you for your help.
Leo

Regarding AttributeError: 'MpvManager' object has no attribute '_sock', it’s unclear what happened since the exact error message wasn’t reported, but the debug script will now use some random name to communicate with mpv and this error probably won’t happen again.

Taking into the account that the debug script works the second time, maybe mpv was just a bit slow to respond the first time for some reason. Maybe increasing the default 1 second timeout to maybe 5 seconds for {"command": ["get_property", "property-list"]} will buy enough time for mpv to reply.

To test it, download the updated gist - anki mpv debug · GitHub - and run the same main.py file once or twice. This time it should fail the first time and maybe the second time too. Then edit mpv.py in any text editor and replace the line #558

        proplist = self.command("get_property", "property-list")

with

        proplist = self.command("get_property", "property-list", timeout=5)

then save the file, run main.py again a few times to see if it works or not.

After that maybe use Windows Task Manager or Process Explorer by Mark Russinovich to close all mpv.exe processes created with the debug script, or log off, restart the PC or do nothing.

1 Like

Hey kelciour

i was now able to reproduce what you described.
And indeed, raising the timeout to 5 seconds did the trick for me.
I did also work at 3 and 4 seconds, 2 seconds was not enough.

here are the logs:

best regards
Leo

Thank you! Maybe with this fix “mpv timed out” won’t happen again and there’s no need to try to investigate it further somehow.

To apply the same fix for Anki 2.1.46,

  1. Install Anki from pip.

    https://github.com/ankitects/anki/blob/main/docs/development.md#pre-built-python-wheels

  2. Add timeout=5 to C:\pyenv\Lib\site-packages\aqt\mpv.py and save the edited file.

  3. Start Anki from cmd with \pyenv\scripts\anki or go to C:\pyenv\scripts\, create a new shortcut for anki.exe and in the Properties > Shortcut change “Run: Normal window” to “Run: Minimized” to “hide” the console window.

If Anki starts fine with the fix but the same error happens again during review, try installing the add-on No Sound Fix (libmpv) - AnkiWeb to see if it makes any difference.

2 Likes