amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Differences between Origin, Iframed, and Webview'd iOS embeds

Open jridgewell opened this issue 9 years ago • 29 comments

We use slightly different embedding hacks in iOS for each of:

  • Origin pages (pages on publisher's origin, or directly accessing CDN page)
  • Iframe'd embeds (publisher or CDN page is embedded in an iframe)
  • Webview'd embeds (publisher or CDN page embedded inside a native webview)

This had led to multiple bugs (b/65225385, b/36068204, https://github.com/ampproject/amphtml/issues/11253#issuecomment-332136756) that are very difficult to test for (who'd think to test the page in Google Search and Google Search App?) and impossible to debug (non-Googlers do not have access to debugging versions of iGSA that connects to Safari Debugger).

We really need to switch to a single embedding type (Iframe'd) that is used in all cases. This will greatly simplify testing and debugging, by creating one single consistent environment.

jridgewell avatar Sep 26 '17 18:09 jridgewell

Definitely unfortunate. But given the ugliness of some solutions for iframes, I'd hesitate to consign other clients to be forced into the same world.

/cc @cramforce

dvoytenko avatar Sep 26 '17 23:09 dvoytenko

+1 Strongly opposed to going iframes everywhere. I think that no-iframes is the more desirable, but that will take a while.

cramforce avatar Sep 27 '17 00:09 cramforce

I see consistency as a better goal than cleanliness, especially if publishers keep hitting "full page is invisible" bugs in webviews.

The wrappers/styles are necessary on origin page so the pubs can built and manually test the page. The fixed position hacks are not, so they don't need to be installed.

jridgewell avatar Sep 27 '17 14:09 jridgewell

Can you quickly explain how the webviews are different from a straight up "load cached page in web browser" page load?

cramforce avatar Sep 27 '17 14:09 cramforce

Pulling from b/65225385#comment12:

The only difference between the webview's Natural viewport and a normal Natural (used in SERP embeds in Android, and all origin pages) is the html.i-amphtml-webview > body style, which adds an explicit overflow-x: hidden; overflow-y: visible;. To be clear, I don't think we should remove this style and make this webview exactly match normal Natural. I think iOS should always use NaturalIosEmbed (in SERP, origin, and webview), and Android should always use Natural. The arguments I can think of against this change is the weird DOM hacks we put in (wrapper body element, styles). But the pros are that it would make any problems clear to the publisher when they test origin sites (what I assume is the most common way to build a page). And we can disable FixedLayer transfer in unneeded cases.

jridgewell avatar Sep 27 '17 14:09 jridgewell

Hmm, having these extra styles (I assume because of swiping?) is, indeed, very unfortunate.

cramforce avatar Sep 27 '17 15:09 cramforce

Swiping, meaning scrolling? Then yup, all the hacks are to make iframes scrollable.

jridgewell avatar Sep 27 '17 15:09 jridgewell

Na, I mean in the webview. Swipe left, right. Could we remove those extra styles?

On Wed, Sep 27, 2017 at 8:15 AM, Justin Ridgewell [email protected] wrote:

Swiping, meaning scrolling? Then yup, all the hacks are to make iframes scrollable.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ampproject/amphtml/issues/11445#issuecomment-332555570, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFeT65PzJm5d9mhetWxuoGKUjIanaWPks5smmZ4gaJpZM4PksWn .

cramforce avatar Sep 27 '17 17:09 cramforce

For feebee case #11253 (comment) , I get feedback from feebee developers: they reduce the style size from 48KB to 44KB and then AMP page gets rendered well.

101keith avatar Sep 28 '17 04:09 101keith

If I remember right, yes, iOS (and even Android) WebViews had problems with ~scrolling~ swiping due to default overflow-x: visible. We had to add those. We can try and set overflow-x: hidden in standalone case. Would that reduce fragmentation?

dvoytenko avatar Sep 28 '17 23:09 dvoytenko

@101keith Thanks for looking into this. It seems like the changes they made are live now and I'm seeing the page render correctly in AMPKit viewers (iGSA).

@dvoytenko When you say iOS (and Android) WebViews had problems with swiping, do you mean swiping left/right like Malte mentioned? Since the embedded webview case doesn't need to swipe (that's handled on the native side) I'm guessing there's something else you're referring to here?

stephen-deg avatar Sep 29 '17 15:09 stephen-deg

@stephen-deg I'm pretty sure it's related to swipe left/right. I know that definitely Android has issues with horizontal swipe as by default the touches are tested against possible horizontal scrolling inside the WebView.

In my notes here, it says:

Set body {overflow-x: hidden} for iOS WebView. This is b/c iOS WebView does NOT respect html {overflow-x: hidden}.

And the best I can find now, this was done due to https://github.com/ampproject/amphtml/issues/3712

PTAL

dvoytenko avatar Oct 02 '17 20:10 dvoytenko

For reference, here's an example of rendering issues under iGSA on a real device. Most AMP results load fine, but there are blank pages at ~36s and ~1:21s in the video:

Screencast: https://photos.app.goo.gl/fD2qr04t6SSXdY942 OS: iOS 11.0.1 Version: Google Search App v35.0.167640935

ithinkihaveacat avatar Oct 09 '17 13:10 ithinkihaveacat

Could anyone explain why body {overflow-x: hidden} would lead to a blank page? Also CC @ericfs

cramforce avatar Oct 09 '17 16:10 cramforce

I think @dvoytenko's history is correct. #3712 was filed because pages with horizontal scrolling caused problems for swiping between documents.

ericfs avatar Oct 09 '17 18:10 ericfs

This is a high priority issue but it hasn't been updated in awhile. @cramforce Do you have any updates?

ampprojectbot avatar Oct 30 '17 20:10 ampprojectbot

This is a high priority issue but it hasn't been updated in awhile. @cramforce Do you have any updates?

ampprojectbot avatar Nov 20 '17 21:11 ampprojectbot

This is a high priority issue but it hasn't been updated in awhile. @cramforce Do you have any updates?

ampprojectbot avatar Dec 04 '17 21:12 ampprojectbot

This is a high priority issue but it hasn't been updated in awhile. @cramforce Do you have any updates?

ampprojectbot avatar Dec 25 '17 21:12 ampprojectbot

This is a high priority issue but it hasn't been updated in awhile. @cramforce Do you have any updates?

ampprojectbot avatar Jan 15 '18 21:01 ampprojectbot