Syncing pops up 2 windows instead of 1

Hello!

I realise this has been the behaviour for as long as I can remember, and it’s been annoying me multiple times a day, every day for many years, but I never thought of asking if it could be changed.

When in Anki Desktop, if you press Sync, a window pops up with no content (it’s even transparent on my laptop, I’m on Ubuntu). It then disappears and a new pop up appears with “syncing”, “checking media” etc depending on the actual syncing needs.

The first pop-up stays on screen for 3 seconds. Usually, I sync when I’m done with Anki and want to switch to another activity and to another window. But then, the second window pops up and brings me back to Anki. What I end up doing is “sync”, wait until the first window is gone and the second is up, and then switch. That’s 3-4 seconds every time I switch to another activity (which can be something like 15 times a day).

Admittedly, this isn’t that much time, but if the two pop-ups were merged into one, or if the second pop-up did not steal focus (i.e. it stayed in the background), my daily experience of Anki would be much better :slight_smile:

I’m happy to propose a fix if needed, but would like to discuss the idea here first.

Can you reproduce the problem with the latest beta? https://betas.ankiweb.net/#/

Ha, it’s gone! Thanks!
Is this a coincidence, or did you just fix it?? I feel this behaviour has been there for years, and just when I ask it goes away :slight_smile:

Is there possibly a stable version that ships this fix yet? (or is the current beta stable enough?)

However, I have written some programs that read from the Anki collection db, and with the new beta, I always get some “sqlite3.OperationalError: database is locked” errors, even when I’m not doing anything with Anki (it’s just “open”).

Is that a known problem, or should I make a report somewhere?

Syncing was updated during the 2.1.28 alphas.

Anki requires exclusive access to the database. You can either return to the profiles window, or close Anki if you need to access Anki’s data files in an external program.

This is a sad development for me as I work both with Anki and tools around, and going back to profiles is impractical. These tools access the db in a read-only fashion. Is there a need for Anki to block the db in read access too?

Yes, an exclusive lock is necessary, and older Anki versions were supposed to behave the same way. You can copy your collection file to another location if you want a read only copy that can be accessed even while Anki has your profile open.

1 Like

That’s a good idea, I’ve checked that copying and reading from there would work. Thanks.
Out of curiosity, what makes it necessary for the lock to exclude reads? As far as I can see, when I switch from Anki to my programs, I’m not using Anki and so there is nothing happening to the db.
(if there is a place I can read about the changes, I’m happy to read that instead)

1 Like

Exclusive access means shared memory is not required for WAL, and means we don’t have to deal with the database being locked by other processes.

I’ve spent a bit of time reading the SQLite docs regarding locs etc and I still don’t understand, but anyway, I’ve implemented a copy-on-the-fly in my program, and so that is sufficient for me at his stage. Thanks again for the suggestion.