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

Multiple unrelated Hypothesis frames on one page causes havoc #249

Closed
nickstenning opened this issue Feb 21, 2017 · 4 comments
Closed

Multiple unrelated Hypothesis frames on one page causes havoc #249

nickstenning opened this issue Feb 21, 2017 · 4 comments
Assignees
Labels

Comments

@nickstenning
Copy link
Contributor

Originally reported as hypothesis/h#3433 by me.

Steps to reproduce

Create an HTML document with multiple frames, each containing an instance of Hypothesis. The frames must all be hosted on the same origin.

For example:

index.html
<!doctype html>

<iframe src="/a.html" style="width:45%;height:500px"></iframe>
<iframe src="/b.html" style="width:45%;height:500px"></iframe>
a.html and b.html
<!doctype html>

<script async src="https://hypothes.is/embed.js"></script>

<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula
eget dolor? Aenean massa? Cum sociis natoque penatibus et magnis dis parturient
montes, nascetur ridiculus mus; Donec quam felis, ultricies nec, pellentesque
eu, pretium quis, sem!
</p>

Expected behaviour

Each independent Hypothesis instance can be used on its own without interfering with the others.

Actual behaviour

The "magic" autodiscovery features cause complete havoc. Specifically:

  • frames disagree on who is the "host" and who is the "guest" causing "A second Discovery server has been detected" errors.
  • frames which contain different documents receive page metadata from the other frames and end up loading the wrong annotations
  • messages bounce endlessly between frames causing problems similar to that described in Show / Hide Highlights endless toggle h#2829.
  • creating an annotation results in annotation editors being displayed in both sidebar applications.
@judell
Copy link
Contributor

judell commented Sep 6, 2017

Today I was working on an integration that uses the standalone viewer, e.g. https://hypothes.is/a/6aknRpHFEeeBWE9crsbjQA, in a iframe on a page that already has an active instance of H.

(Why? Because that view is a useful embeddable widget that can enable display of, and interaction with, a individual annotation and its replies.)

As in other scenarios this one triggers "A second Discovery server has been detected" . For this particular use case, since the embedded stream has no concept of, nor need for, a guest/host relationship, it seems possible, and maybe appropriate/useful to return from startDiscovery if document.location.href starts with SERVICE_URL/a.

@robertknight
Copy link
Member

I started putting together a prototype a while back to explore how to simplify the way the sidebar and content frames discover each other. It can be found at https://github.com/hypothesis/client/tree/new-discovery-prototype/discovery-prototype.

@klemay
Copy link
Contributor

klemay commented Nov 9, 2020

adding to backlog in favor of #187

@robertknight
Copy link
Member

robertknight commented Jul 29, 2021

This was fixed initially by #3599 and then #3611 replaced the whole mechanism that is used by frames to discover each other. There is ongoing work in #3533 which will lift the restriction that host and guest frames must be same-origin.

In the client's development server there is a manual test page for this at http://localhost:3000/document/multi-frames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants