client icon indicating copy to clipboard operation
client copied to clipboard

Annotations can fail to anchor on client-rendered pages if content is slow to load

Open robertknight opened this issue 2 years ago • 1 comments

@jeremydean reported an issue where annotations in the Public channel would sometimes all orphan on https://via.hypothes.is/https://platform.openai.com/docs/chatgpt-education despite the associated content still being there.

At the time of writing, https://platform.openai.com/docs/chatgpt-education is a client-side rendered React app that appears not to have any kind of server-side rendering set up. When accessing this page through Via, I see that the Hypothesis client sometimes loads faster than the page itself. At the point where the client tries to anchor annotations in the page, if the content has not yet loaded then they will orphan.

The issue here is partly to do with Via, since it exacerbates the time taken for the content to load, but in principle the issue could happen outside of Via too, for any situation where a client-rendered page takes a long time to fetch its content.

Solving the completely general issue of re-anchoring annotations when any page content changes, even if the URL hasn't changed, might be expensive from a performance point of view. Also we want to be careful about logic that could cause annotations to move between the Annotations and Orphans tab while the user is interacting with them. However we can probably do something more constrained to handle this situation.

Some ideas:

  • Defer anchoring annotations in the guest if the page is largely blank (TBD how "blank" is determined)
  • Add some mechanism for the guest to detect major content changes and retry anchoring of orphans. Be careful about performance here.

robertknight avatar Feb 10 '23 08:02 robertknight

This may have some connection to https://github.com/hypothesis/client/issues/5568.

robertknight avatar Jun 28 '23 09:06 robertknight