Skip to content

Fix manga details for non-library manga taking longer to load#3055

Open
FlaminSarge wants to merge 3 commits intomihonapp:mainfrom
FlaminSarge:details-perf-fix
Open

Fix manga details for non-library manga taking longer to load#3055
FlaminSarge wants to merge 3 commits intomihonapp:mainfrom
FlaminSarge:details-perf-fix

Conversation

@FlaminSarge
Copy link
Copy Markdown
Contributor

@FlaminSarge FlaminSarge commented Mar 12, 2026

Fixes #3027
Regression from #2955 (probably)

Moves setDefaultChapterFlags after the initial load so at least the Manga details page shows up while fetches are still happening. Also avoids setting default chapter flags if default is the same as the manga's current flags (for no defaults set or if this is reopening a non-favorite).

The problem seemed to be that the mangas DB write from setMangaDefaultChapterFlags had to wait for a long time (150+ms on my emulator with a 6000+ library). Not sure if that's due to the mutex changes for DB transactions or something else, but on top of that it also increased the time that availableScanlators and excludedScanlators took; also unsure why that is.

Before these changes, timing was something like this:

  D  MangaScreen [<title>] awaitManga: 0ms
  D  MangaScreen [<title>] awaitChapters: 1ms
  D  MangaScreen [<title>] setDefaultFlags: 179ms
  D  MangaScreen [<title>] availableScanlators: 296ms
  D  MangaScreen [<title>] excludedScanlators: 379ms
  D  MangaScreen [<title>] State.Success: 381ms

After the changes:

  D  MangaScreen [<title>] awaitManga: 0ms
  D  MangaScreen [<title>] awaitChapters: 1ms
  D  MangaScreen [<title>] availableScanlators: 2ms
  D  MangaScreen [<title>] excludedScanlators: 2ms
  D  MangaScreen [<title>] State.Success: 2ms
  D  MangaScreen [<title>] setDefaultFlags: 422ms

And if setting the default flags gets to no-op because the default chapter flags are 0 or the same as before, that takes barely any time as well.

availableScanlators/excludedScanlators await's don't have to be moved out of the state update block, but I figured it doesn't hurt and can prevent pain later if those also need to be debugged again (moved them around to get timings for those initially, left them there afterwards).

@FlaminSarge
Copy link
Copy Markdown
Contributor Author

Note that this should still probably go in despite #2982 being a good rework of the root cause, since currently any time a non-favorite is opened it triggers a mangas db write when it doesn't need to.

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.

The manga page accessed from the search within an extension became slower, and the overall handling of these items became slower.

2 participants