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

[Bug] Degrading performance with each card reviewed #12980

Open
3 of 4 tasks
JackdawInteractive opened this issue Dec 15, 2022 · 22 comments
Open
3 of 4 tasks

[Bug] Degrading performance with each card reviewed #12980

JackdawInteractive opened this issue Dec 15, 2022 · 22 comments
Labels
Help Wanted Requesting Pull Requests from volunteers Keep Open avoids the stale bot Priority-High
Milestone

Comments

@JackdawInteractive
Copy link

JackdawInteractive commented Dec 15, 2022

I've recently started to have serious issues with reviews becoming unbearably slow in the app. It seems to clear if I restart the app, but reappears gradually as I review. The result is a consistent full second delay after pressing to view the answer and pressing good. Outside of reviews, performance on my phone is smooth and responsive. Issue only cropped up in the last week. Possibly related to a recent WebView for Android update.

Edit: Discovered that just leaving the deck review and re-entering resets the lag build-up. Memory leak?

Update: The latest WebView patch reduced the severity of the issue, but the behaviour remains. Performance degrades gradually with each card reviewed until I close and reopen the deck.

Reproduction Steps
  1. Open the app.
  2. Review 25 or more cards.
  3. Latency increases with each review.
Expected Result

Reasonable performance.

Actual Result

Consistent one second latency on every button press during reviews.

Debug info

Refer to the support page if you are unsure where to get the "debug info".

AnkiDroid Version = 2.15.6

Android Version = 12

Manufacturer = Sony

Model = XQ-BT52

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 12; XQ-BT52 Build/62.1.A.0.675; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/108.0.5359.79 Mobile Safari/537.36

ACRA UUID = 90492a50-8790-49c3-a61a-c6b5cf661452

Scheduler = std

Crash Reports Enabled = true

DatabaseV2 Enabled = true

Research

Enter an [x] character to confirm the points below:

  • I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
  • I have checked the manual and the FAQ and could not find a solution to my issue
  • I have searched for similar existing issues here and on the user forum
  • (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)
@JackdawInteractive JackdawInteractive changed the title [Bug] Extreme lag while reviewing [Bug] Degrading performance with each card reviewed Dec 16, 2022
@JackdawInteractive
Copy link
Author

It appears my issue is a duplicate of this, the symptoms match:
#12034

Removing font-family: arial; from my card CSS appears to have resolved the performance issues. It appears I also neglected to mention that I get the same webView crashes after switching to another app without closing AnkiDroid.

@habbbe
Copy link

habbbe commented Jan 25, 2023

Just to add to my own experience on this issue:

I experienced the same problem on a Samsung S8, however, when switching to a Samsung S10 the issue was resolved, but only for a few days.

This led me to try to clear all the data for the AnkiDroid via the app preferences, and resyncing my decks. This again solved the problem for me, and I've now been using the app without issue for about a week.

I have yet to try to remove font-family: arial; from the CSS, but will do so if the problem occurs again.

@github-actions
Copy link
Contributor

Hello 👋, this issue has been opened for more than 3 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Apr 25, 2023
@david-allison david-allison added Keep Open avoids the stale bot and removed Stale labels Apr 25, 2023
@briankrznarich
Copy link

briankrznarich commented Feb 7, 2024

Still an issue in the beta.

Just to add a datapoint. I have experienced this problem for several years, and gave up on it getting fixed. I now do reviews of perhaps a couple-hundred cards, and as I feel things slow down (card-to-card rendering time), I go to the task manager, kill ankidroid and restart the app. It's not uncommon to do this 2 or 3 times per day. Takes about 10 seconds, so I just got used to it.

I don't kill the app myself, ankidroid will keep slowing down till it crashes, and certain new-card progress will potentially be lost. (At least in the past, my reviews would be saved, but Ankidroid would 'forget' that I had done 15 of 30 'new' cards for the data, and I'd come back after crash with 30 'new' cards. This may have been fixed. )

I review Japanese. I use two different custom fonts (a pretty handwritten font, and a stroke-order font), in addition to the system Japanese fonts. These are bundled as deck media in the usual anki way.

I also have audio on many of the cards, which could figure into things, but a lot of finger-pointing has been done at fonts over the years, so that seems to be the culprit.

armchair-quarterbacking, I've long wondered: if the underlying issue is a chrome webview not cleaning up cache, is there not something that Ankidroid could periodically explicitly destroy and recreate just to work around this issue? Is there a chrome cache that cannot be cleared except by terminating all of Anki? I realize this wouldn't feel like a "clean" solution, but clearly whatever google changed, it's been broken for several years and they aren't fixing it. (Other tickets have this tagged as "upstream issue", I guess hoping google will do something...)

There was a long period where things worked fine many years ago, then a change in chrome's core webview sparked the issue. There was a small window where it was possible to manually install an older version of the chrome webview component to fix the problem, but that stopped working many, many versions of Android ago.

To link together some likely-related issues:
Changing Japanese font slows down ankidroid considerably #4856
Possible memory leak? #11620
[Bug] RAM usage keeps increase if deck use custom font #12034 (this has already been noted)

As you can see, this keep getting closed and forgotten. #4856 in particular was opened in 2018.

Closed as "I'm going to close this because there is nothing we can do, and even when fixed there will be no action to take that I'm aware of. But I have starred the bug upstream and I recommend anyone interested in the resolution to do the same"

Here's the upstream chromium ref, whose last comment was in 2019:
https://issues.chromium.org/issues/40586080#comment14

The last note on #11620 is:
I've been having the same issue. My very simple workaround is: when it starts to get slow, I go back to Ankidroid home screen and hit synch. Then it's back to a fresh start right away. Maybe this helps!

If that's the case, it seems that periodically discarding & recreating something could be a workaround. Don't know how hard it would be to do that in a 'seamless' way.

@david-allison
Copy link
Member

david-allison commented Feb 9, 2024

We need to get a reproduction case: this should be fairly feasible with an emulator

I'd then propose resetting the WebView every 50 reviews, and see if this resolves the issue

@david-allison david-allison added the Help Wanted Requesting Pull Requests from volunteers label Feb 9, 2024
@briankrznarich
Copy link

I am a developer but I don't do Android development (I'm sure I could get an emulator running locally). Do you think I could just get you a copy of my deck? I imagine tapping "good good good" for a couple of minutes at high speed would reproduce. I can start by stripping the audio (to save space) and reproducing on a spare pixel3a to make sure it should crash before sending something along.

I don't have anything I consider private in my actual deck, so no worries there. What do you think?

It will take some time, but if you need me to set up an emulator I can do it. You'll need to let me know what I need to get to you.

@david-allison david-allison added this to the 2.18 release milestone Feb 10, 2024
@david-allison
Copy link
Member

I strongly suspect the issue is the font, and the ideal would be to find something GPL-compatible which we could add to the repo. From there, automating the emulator is simple.

Right now, I'm snowed under and I won't have the time to take this up.

Let's schedule it for 2.18. We've got a ton of people waiting for 2.17, and I'd rather focus efforts towards getting our final blocking bugs fixed.

@briankrznarich
Copy link

No rush. It's been this way for quite a while, I'm pretty excited to see that you're interested in taking it up. I'll try to keep an eye on this ticket for updates, and if there's anything I can provide (with in my means) I will try to help out.

@mikehardy mikehardy modified the milestones: 2.18 release, 2.19 release May 13, 2024
@epistularum
Copy link

Same behavior but in my case it crashes every 20 cards or so. This also crashes all other open apps. After the crash every single card gets slower and slower to load. This has been a constant struggle for years and makes the app barely usable.

AnkiDroid Version = 2.18.4 (f867da96b8304edaebd0361326316bc7514f8cde)

Backend Version = 0.1.38-anki24.04.1 (24.04.1 ccd9ca1a8309b80bcb50ddc5d99c7ce63440bce9)

Android Version = 14 (SDK 34)

ProductFlavor = full

Manufacturer = Google

Model = Pixel 5a

Hardware = barbet

Webview User Agent = Mozilla/5.0 (Linux; Android 14; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.159 Mobile Safari/537.36

ACRA UUID = 08b9fc4e-4a3e-4cd2-856b-89f1be9b226e

FSRS Enabled = true

Crash Reports Enabled = true

@amadareRythm
Copy link

As asked by David, I'm reporting I also have this issue. Here's my original message posted on another social:

Device: OnePlus 10T 5G (8GB of RAM)

When I use the app, after roughly 10 minutes it slowly slows down, becoming more and more sluggish until it eventually freeze completely. The system becomes unresponsive and I'm stuck in the Anki frozen screen. After some time (about a minute) it crashes. Sometimes the toast message "WebView out of memory" (or something similar, I didn't memorize it) pops up.

The cards are pure text, no media of any kind included, but it does use a third-party font, and I've used the same deck on a different device (an older Asus) and it worked flawlessly without any issue. (But it also used an older AnkiDroid version)

My device has no issues with any other application, including intensive 3D videogames.

As other users said, while freezing the phone is indeed an issue, I've became accustomed to terminate the app as soon as it slows down, so ultimately I have established a habit of fixing it manually, but if this issue could be solved it would help a lot.


AnkiDroid Version = 2.20.0 (d41d16a)

Backend Version = 0.1.48-anki24.11 (24.11 c47638ca36f99dd4f3b81ae82d964aec66e392e0)

Android Version = 14 (SDK 34)

ProductFlavor = play

Manufacturer = OnePlus

Model = CPH2415

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 14; CPH2415 Build/UKQ1.230924.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/131.0.6778.41 Mobile Safari/537.36

ACRA UUID = 181c0e00-d376-4a08-a338-7af29d2c7cb8

FSRS = 1.4.3 (Enabled: true)

Crash Reports Enabled = true

@david-allison
Copy link
Member

david-allison commented Dec 11, 2024

@BrayanDSO would you accept a patch to reinit the WebView every ~50 cards or so for the new Reviewer?

@BrayanDSO
Copy link
Member

I don't know if that also happens there. The new reviewer is only recreated in some System configuration changes, which is way way less than the legacy reviewer, that recreates it in every card (I don't recall if it happens when flipping a card as well). Maybe that's a problem with how the old instances are garbage collected.

If it happens there and (ideally) we have a reproduction case, I'd be fine with reinitializing the webview based on some kind of parameter if that really can fix the issue. The legacy reviewer does that in every card and the issue still exists.

For now, I suggest waiting for a confirmation.

@david-allison
Copy link
Member

I wasn't aware that the WebView was reinitialized on each card load, I thought it was a page load


That being said: @amadareRythm

Could you

  • Go to Settings - About AnkiDroid
  • Tap the AnkiDroid logo 6 times
  • Enable developer mode
  • In the developer settings, tap "New Reviewer"
    • This is stable as far as I know, but feature incomplete

@amadareRythm
Copy link

@david-allison Sure thing. I've just enabled the New Reviewer and will report back tomorrow after my daily study session.

@amadareRythm
Copy link

I did my study session with the new reviewer and, for the first time since I don't know how much, it didn't had the problem. It's only one singular test so it might have been just a coincidence. Still, it's promising. I'll test for another week and report back.

@briankrznarich
Copy link

Another positive datapoint @david-allison
I saw the new comments and enabled the developer-mode reviewer to test it out. I've done about a thousand cards over the last few days. No slowdowns, no hangs. Looks like the release of the new viewer should finally resolve this issue!

I had no unexpected problems during the reviews. The new reviewer looks and feels nice, and for the most part I barely noticed any difference vs. the classic card reviewer.

Two non-trivial notes just in case:

  1. There's no "time remaining". I hope there are still plans for this...
  2. No undo-button on the main screen(only in the menu). I'm sure this is just because it's in development, but this would be sorely missed.

And a more minor observation:

  1. The horizontal margins (unused space) are larger. I probably wouldn't have noticed, but I had a large kanji font sized to fit 7 characters per line, and had to shrink the font in my template a bit to get this back. I'm not going to lose any sleep over this, but margin-size and wasted space on already-small screens might be worth reviewing. Some quick math suggests 15% of my screen width is now unused/unusable.

Old/Current Margins (I crammed as much in as I could)
Image
New Margins
Image

Thanks as always.

@BrayanDSO

This comment has been minimized.

@briankrznarich

This comment has been minimized.

@BrayanDSO

This comment has been minimized.

@BrayanDSO

This comment has been minimized.

@epistularum
Copy link

After thousands of reviews, I can confidently say this is the first time in years I've experienced responsive card flipping. As a dedicated AnkiDroid user, this update is easily one of the best things to happen to me in 2024.

Absolutely incredible work, I'm beyond grateful!

@amadareRythm
Copy link

After a whole week of use and thousands of reviews I can confirm as well that the problem seems fixed. I'm so glad the problem has been already solved, plus, I really like the design of the new reviewer.

Thank you all to the people involved, I love AnkiDroid and this issue was a real nuisance, slowing down every study session. Now, I can focus more on the study AND finish earlier than before. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Requesting Pull Requests from volunteers Keep Open avoids the stale bot Priority-High
Projects
None yet
Development

No branches or pull requests

8 participants