Skip to content

fix(404Anime): read presence data from the DOM instead of an async bridge#11031

Open
sankeer28 wants to merge 5 commits into
PreMiD:mainfrom
sankeer28:fix/404anime-updatedata-performance
Open

fix(404Anime): read presence data from the DOM instead of an async bridge#11031
sankeer28 wants to merge 5 commits into
PreMiD:mainfrom
sankeer28:fix/404anime-updatedata-performance

Conversation

@sankeer28

@sankeer28 sankeer28 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What was wrong

Discord's status was never updating for people watching on 404Anime. UpdateData awaited an async bridge read (execInPage/getPageVariable) on every tick to get the page's presence data. UpdateData fires far more often than that round trip can finish, so calls piled up and the extension logged UpdateData execution is too slow! Skipped N updates, skipping most updates.

The fix

Read the data from a hidden DOM element the site renders instead of an async bridge call. This matches how every other activity in this repo reads its data. It's synchronous, so UpdateData never awaits anything and can't fall behind.

Acknowledgements

Tested and works

image

UpdateData awaited execInPage/getPageVariable on every tick, which fires
more often than that round trip completes. Calls backed up and the
extension logged 'UpdateData execution is too slow' while skipping most
updates, so Discord activity never refreshed for real users. Poll the
bridge on our own 1s interval instead and have UpdateData read the cached
result synchronously.
@dimerp

dimerp Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🖼️ Activity asset preview

Another day, another diff. Here's everything shiny I could dig out of this one.

404Anime (websites/0-9/404Anime) — update

Preview Source URL
logo https://cdn.rcd.gg/PreMiD/websites/0-9/404Anime/assets/logo.png
thumbnail https://cdn.rcd.gg/PreMiD/websites/0-9/404Anime/assets/thumbnail.png

Beep boop — I refresh this comment on every push, so no need to scroll. 🤖

…idge

The previous fix (poll + cache) worked around execInPage's round-trip
latency without removing it. Every other activity in this repo reads
its data straight from the page's DOM, which is synchronous — no
cross-realm message-passing needed. Switch to that pattern: the site
now renders a hidden #s-anime-premid element with the presence data as
data-* attributes, and UpdateData reads it directly with no async call
at all, removing the "UpdateData execution is too slow" risk entirely
instead of just reducing how often it's hit.
@sankeer28 sankeer28 changed the title fix(404Anime): stop UpdateData from awaiting the page-bridge read inline fix(404Anime): read presence data from the DOM instead of an async bridge Jul 22, 2026

@skullysmods skullysmods left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump version in metadata

@sankeer28
sankeer28 requested a review from skullysmods July 23, 2026 22:25
@skullysmods
skullysmods enabled auto-merge (squash) July 24, 2026 08:48
@skullysmods
skullysmods requested a review from a team July 24, 2026 08:48

@Bas950 Bas950 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly the async one is probably better but it should be cached so it doesnt keep requesting it if there are no changes.

auto-merge was automatically disabled July 24, 2026 21:10

Head branch was pushed to by a user without write access

@sankeer28

sankeer28 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Added some caching

@sankeer28
sankeer28 requested a review from Bas950 July 24, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants