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

Twitter widget sometimes fails to render on iOS #7482

Closed
cramforce opened this issue Feb 10, 2017 · 6 comments
Closed

Twitter widget sometimes fails to render on iOS #7482

cramforce opened this issue Feb 10, 2017 · 6 comments

Comments

@cramforce
Copy link
Member

This repros about 50% of the time on https://www.google.com/amp/s/www.washingtonpost.com/amphtml/news/the-fix/wp/2017/02/09/donald-trump-finally-met-his-match-the-courts/?client=safari

If it does not repro after a few tries restart Safari and try again.

The tweet will load eventually, but it often take 1 to 2 minutes.

Based on the network tab the requests to get the tweet content run much earlier. When it renders only CSS files and the user images are retrieved.

It seems that this may be a bug in Safari where Safari somehow fails to realize that the frame is in view and throttles its painting.

@cramforce cramforce added this to the Pending 3P Implementation milestone Feb 10, 2017
@cramforce
Copy link
Member Author

CC @indianburger

When you inspect the iframe in Safari devtools it always immediately renders correctly

@cramforce
Copy link
Member Author

I dug a bit deeper and the problem is definitely that the promise returned by twttr.widgets.createTweet (https://github.com/ampproject/amphtml/blob/master/3p/twitter.js#L74) never resolves. @indianburger solved this before in a similar situation. My guess is that Safari throttles a requestAnimationFrame and then never runs it.

A few suggestions

  • Do not use requestAnimationFrame when framed
  • also call a setTimeout and flush rendering based on that when it arrives earlier.

@cramforce
Copy link
Member Author

Here is the last bug there this same thing happened #3220 @indianburger fixed it on Twitter's side.

@indianburger
Copy link
Contributor

Thanks for flagging it and digging into the problem. A fix was deployed last night/this morning for this.

The culprit was indeed requestAnimationFrame which we use for batching DOM reads and writes, and requestAnimationFrame gets really throttled in mobile safari. The fix was to back it up with a setTimeout as suggested. The setTimeout is not aggressive (500ms) to allow requestAnimationFrame to work in normal circumstances. Sometimes it takes 2-3 seconds for all the timeouts to expire before the Tweet is rendered in mobile safari.

Let me know if you still see issues on your end.

@cramforce
Copy link
Member Author

Thanks @indianburger. We'll monitor!

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

No branches or pull requests

2 participants