ampproject / ampproject/amphtml

Bento components sporadically fail to render on Transformed (SSR'ed) AMP pages

Open
#35,485 7 comments 1 reaction 1 assignee Claimed by @caroqliu View on GitHub
Stale Type: Bug WG: bento
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

I've come across a strange issue where Bento components sporadically fail to render when they appear on some transformed AMP pages (i.e. SSR'ed with AMP Optimizer). I've put together a test case to demonstrate: https://amp-bento-component-ssr-init-fail.glitch.me/

See the following video for the buggy behavior in the third iframe with the heading “With WP Admin Bar w/ SSR”, after I reload the page a couple times:

https://user-images.githubusercontent.com/134745/127750999-e6e938e6-5d79-45a0-9d39-ad5be5c65960.mov

This SSR'ed AMP with the WordPress admin bar consistently fails to have the `amp-youtube` and `amp-video` Bento components render.

Pass | Fail
-----|-----
![image](https://user-images.githubusercontent.com/134745/127751259-762870b3-8d9a-4dce-8ea7-a0b8f87e3dda.png) | ![image](https://user-images.githubusercontent.com/134745/127751214-9914685d-69a0-45c9-aa28-1198e05fe4fa.png)

The difference between the two is the `i-amphtml-sizer` element. In the working version, it has the `slot="i-amphtml-svc"` attribute whereas in the failing version, this `slot` attribute is absent.

The markup pre-SSR:

```html






```

The markup after SSR:

```html












```

When the WordPress admin bar is present (in which case the SSR'ed Bento components often fail to render), the following changes are present:

1. Additional stylesheets are added.
2. Additional scripts are added.
3. Additional HTML elements are added.

There seems like a race condition going on, and it may be that the additional stylesheets and scripts are making the race condition more likely to happen.

### Reproduction Steps

Go to https://amp-bento-component-ssr-init-fail.glitch.me/ (and potentially reload the page) to see the third iframe have Bento AMP components that fail to load.

I can reproduce consistently in Chrome, Edge, and Safari. In Firefox I've been able to reproduce the issue less frequently, mainly after doing hard refreshes.

### Relevant Logs

_No response_

### Browser(s) Affected

Chrome, Firefox, Safari, Edge

### OS(s) Affected

_No response_

### Device(s) Affected

_No response_

### AMP Version Affected

2107170150000

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.