ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

[amp-next-page] AMP Client ID changes when scrolling through to amp-next-page in AMP Viewer #32305

Closed Cauchon closed 3 years ago

Cauchon commented 3 years ago

What's the issue?

The AMP Client ID (used in amp-analytics) is changing on scrolling into amp-next-page in an amp viewer (but not on publisher origin).

How do we reproduce the issue?

Please provide a public URL and ideally a reduced test case (e.g. on jsbin.com) that exhibits only your issue and nothing else. Provide step-by-step instructions for reproducing the issue:

  1. Go to https://www.google.com/amp/s/www.cnet.com/google-amp/news/nasa-curiosity-rover-snaps-dramatic-mars-selfie-at-scenic-mont-mercou/ in mobile emulator with network tab open in Devtools.
  2. Scroll through and into the second article.
  3. Search for "v56=&AQE=1" in the network tab. You should see two records. Compare the vid query params for each of them. They are distinct even though they are for the same session. (If you open another tab and go to, for example, https://www.google.com/amp/s/www.cnet.com/google-amp/news/nasa-curiosity-rover-snaps-dramatic-mars-selfie-at-scenic-mont-mercou/ and scroll through, you will see that the client id of the first article will correspond to that of the first article of the previous stream you looked at, but the second article won't)

What browsers are affected?

Viewer only. Chrome

Which AMP version is affected?

2101211748002

(cc @dmanek)

micajuine-ho commented 3 years ago

cc @dmanek Maybe we should take a look at this during fixit week :)

micajuine-ho commented 3 years ago

~To recap the situation...~

Edit: After more investigation, I was able to find the root cause of this issue. Contrary to my first thoughts about a problem with amp-next-page's children being iframes that had separate CID instances, it turns out that 1.) amp-next-page inserts children via shadowdocs 2.) The divergence in CIDs between host page and children was occurring due to the fact that the Host Page was using Viewer CID API and the child pages are not (instead using scopeBaseCid_)

anooplath commented 2 years ago

Was this resolved ? I am having same issue for amp-next articles.