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

Inconsistent re-anchoring in multi-guest scenarios #3992

Closed
esanzgar opened this issue Dec 3, 2021 · 1 comment · Fixed by #4131
Closed

Inconsistent re-anchoring in multi-guest scenarios #3992

esanzgar opened this issue Dec 3, 2021 · 1 comment · Fixed by #4131
Assignees

Comments

@esanzgar
Copy link
Contributor

esanzgar commented Dec 3, 2021

Re-anchoring of annotations is inconsistent when there are several guest frames. This is because the sidebar send to all the guest frames the annotations. Every frame tries to anchor the best it can, and depending of the timing of the reporting the annotation can be tagged as orphan.

Scenario 1 (re-anchored to several guest frames)

Steps to reproduce

  1. Go to http://localhost:3000/document/cross-origin-iframe
  2. Make an annotation on a very common word
  3. Reload the page
  4. The annotation will be anchor in both frames

Expected behaviour

It should only be anchored to the frame where the annotation was made.

Actual behaviour

It appears on both frames

Browser/system information

All browsers

Screen.Recording.2021-12-03.at.17.51.19.mov

Scenario 2 (anchored correctly, reported as orphan)

Steps to reproduce

  1. Go to http://localhost:3000/document/cross-origin-iframe
  2. Make an annotation on very long phrase or paragraph
  3. Reload the page
  4. The annotation will correctly anchor in one frames, but it could be reported as orphan.

Expected behaviour

It should only be anchored to the frame where the annotation was made, and it should be numbered in the Annotations tab.

Actual behaviour

It sometimes appears on Orphan tab.

Browser/system information

All browsers

Screen.Recording.2021-12-03.at.17.49.48.mov
@robertknight
Copy link
Member

This is related to one of the sub-tasks in #3798, so I edited that issue's description to reference this one. The description in that issue mentions two different ways of fixing the problem in the VitalSource context:

  1. Don't load the guest functionality in the host frame, so there is only one guest.
  2. Send annotations only to the correct frame when there are multiple guests

This issue discusses the second solution, which we need to support multiple guests in the general context. In an ebook reader, the first would be sufficient.

robertknight added a commit to robertknight/client that referenced this issue Jan 12, 2022
When the sidebar is connected to multiple guest frames it will send all
incoming annotations to all frames. The result is typically that the
annotation will anchor in one frame and orphan in the others. Depending
on what order this happens in, the annotation will non-deterministically
show up as an Annotation or Orphan in the sidebar.

In order to determine which frames an annotation should be sent to in
all cases, we'd either need the backend to return information about which
search URIs an annotation matches or make a separate search request for
each frame and record the associated frame with the results. This
will require some significant refactoring of the annotation search
service.

As an interim step, make `FrameSyncService` send annotations only to a
single frame based on matching URL, with a fallback to sending to the
main frame if there is no exact match. This will work as expected for
most pages, and is at least deterministic when it does fail. When we
have a solution for being able to match annotations to frames more
generally, we can adapt this code to use it.

This is a partial solution to hypothesis#3992.
@robertknight robertknight self-assigned this Jan 21, 2022
robertknight added a commit that referenced this issue Jan 21, 2022
When the sidebar is connected to multiple guest frames it will send all
incoming annotations to all frames. The result is typically that the
annotation will anchor in one frame and orphan in the others. Depending
on what order this happens in, the annotation will non-deterministically
show up as an Annotation or Orphan in the sidebar.

In order to determine which frames an annotation should be sent to in
all cases, we'd either need the backend to return information about which
search URIs an annotation matches or make a separate search request for
each frame and record the associated frame with the results. This
will require some significant refactoring of the annotation search
service.

As an interim step, make `FrameSyncService` send annotations only to a
single frame based on matching URL, with a fallback to sending to the
main frame if there is no exact match. This will work as expected for
most pages, and is at least deterministic when it does fail. When we
have a solution for being able to match annotations to frames more
generally, we can adapt this code to use it.

This is a partial solution to #3992.
robertknight added a commit that referenced this issue Jan 26, 2022
When the sidebar is connected to multiple guest frames it will send all
incoming annotations to all frames. The result is typically that the
annotation will anchor in one frame and orphan in the others. Depending
on what order this happens in, the annotation will non-deterministically
show up as an Annotation or Orphan in the sidebar.

In order to determine which frames an annotation should be sent to in
all cases, we'd either need the backend to return information about which
search URIs an annotation matches or make a separate search request for
each frame and record the associated frame with the results. This
will require some significant refactoring of the annotation search
service.

As an interim step, make `FrameSyncService` send annotations only to a
single frame based on matching URL, with a fallback to sending to the
main frame if there is no exact match. This will work as expected for
most pages, and is at least deterministic when it does fail. When we
have a solution for being able to match annotations to frames more
generally, we can adapt this code to use it.

This is a partial solution to #3992.
@esanzgar esanzgar linked a pull request Feb 1, 2022 that will close this issue
2 tasks
robertknight added a commit that referenced this issue Feb 1, 2022
When the sidebar is connected to multiple guest frames it will send all
incoming annotations to all frames. The result is typically that the
annotation will anchor in one frame and orphan in the others. Depending
on what order this happens in, the annotation will non-deterministically
show up as an Annotation or Orphan in the sidebar.

In order to determine which frames an annotation should be sent to in
all cases, we'd either need the backend to return information about which
search URIs an annotation matches or make a separate search request for
each frame and record the associated frame with the results. This
will require some significant refactoring of the annotation search
service.

As an interim step, make `FrameSyncService` send annotations only to a
single frame based on matching URL, with a fallback to sending to the
main frame if there is no exact match. This will work as expected for
most pages, and is at least deterministic when it does fail. When we
have a solution for being able to match annotations to frames more
generally, we can adapt this code to use it.

This is a partial solution to #3992.
robertknight added a commit that referenced this issue Feb 2, 2022
When the sidebar is connected to multiple guest frames it will send all
incoming annotations to all frames. The result is typically that the
annotation will anchor in one frame and orphan in the others. Depending
on what order this happens in, the annotation will non-deterministically
show up as an Annotation or Orphan in the sidebar.

In order to determine which frames an annotation should be sent to in
all cases, we'd either need the backend to return information about which
search URIs an annotation matches or make a separate search request for
each frame and record the associated frame with the results. This
will require some significant refactoring of the annotation search
service.

As an interim step, make `FrameSyncService` send annotations only to a
single frame based on matching URL, with a fallback to sending to the
main frame if there is no exact match. This will work as expected for
most pages, and is at least deterministic when it does fail. When we
have a solution for being able to match annotations to frames more
generally, we can adapt this code to use it.

This is a partial solution to #3992.
robertknight added a commit that referenced this issue Feb 2, 2022
When the sidebar is connected to multiple guest frames it will send all
incoming annotations to all frames. The result is typically that the
annotation will anchor in one frame and orphan in the others. Depending
on what order this happens in, the annotation will non-deterministically
show up as an Annotation or Orphan in the sidebar.

In order to determine which frames an annotation should be sent to in
all cases, we'd either need the backend to return information about which
search URIs an annotation matches or make a separate search request for
each frame and record the associated frame with the results. This
will require some significant refactoring of the annotation search
service.

As an interim step, make `FrameSyncService` send annotations only to a
single frame based on matching URL, with a fallback to sending to the
main frame if there is no exact match. This will work as expected for
most pages, and is at least deterministic when it does fail. When we
have a solution for being able to match annotations to frames more
generally, we can adapt this code to use it.

This is a partial solution to #3992.
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 a pull request may close this issue.

2 participants