amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

[amp-ad] Shifted amp-ad on Android 4.2.2 system browsers

Open lannka opened this issue 10 years ago • 25 comments

Same error has been seen on desktop Safari 7 as well.

screenshot_20161101-154454

lannka avatar Nov 01 '16 22:11 lannka

It only happens to doubleclick ads.

@tdrl @keithwrightbos can it caused by the centering doubleclick is doing?

screenshot_20161101-161611

lannka avatar Nov 01 '16 23:11 lannka

Do you have an AMP version number and repro page for this? (Looks like you could repro on the a4a.amp.html example page?)

tdrl avatar Nov 02 '16 13:11 tdrl

@glevitzky -- Trying to assign you to this Issue, but the assignment box isn't allowing me to. :-P

tdrl avatar Nov 02 '16 13:11 tdrl

Are there any more details on how to reproduce this? I'm not seeing anything unusual in a4a.amp.html.

glevitzky avatar Nov 02 '16 14:11 glevitzky

Okay, I was able to reproduce using my personal phone's default browser. Now to figure out a way how to debug this...

glevitzky avatar Nov 02 '16 15:11 glevitzky

Reproducible on ads.amp.html. You should be able to see it on desktop Safari 6 and 7 as well. We used Saucelabs to have older version of Safari (remember to turn on developer option in Safari preference).

For Android 4.2.2 system browser, I honestly don't know how to debug :-(. Chrome cannot attach to it.

@cramforce do we need to whitelist @glevitzky so that we can assign bug to him?

lannka avatar Nov 02 '16 16:11 lannka

@lannka I invited them.

cramforce avatar Nov 02 '16 19:11 cramforce

@glevitzky not sure if you need to accept any invitation. i still can't assign to you yet.

lannka avatar Nov 02 '16 21:11 lannka

Is this something I would get via email or github? I don't see anything in either.

glevitzky avatar Nov 02 '16 21:11 glevitzky

You would have to join the ampproject. Go there, you should see a notification at the top of the page.

jridgewell avatar Nov 02 '16 21:11 jridgewell

Ah, thanks! Invitation accepted.

glevitzky avatar Nov 02 '16 21:11 glevitzky

Alright, after spending most of the day rewiring things so that I can test my local code changes in a locally running instance of Android, I can confirm that the issue is in fact the ad centering code that was added as part of the multi-size feature.

As for the solution, should we do some sort of carve out by user agent? I.e., if we detect that the user is on an Android system browser, don't center the ad? And likewise for desktop Safari 7? I'm not really sure what else could be done.

glevitzky avatar Nov 02 '16 22:11 glevitzky

So it's this piece of code? Do you know which one is badly supported?

  const container = global.document.querySelector('#c');
  container.style.top = '50%';
  container.style.left = '50%';
  container.style.bottom = '';
  container.style.right = '';
  container.style.transform = 'translate(-50%, -50%)';

BTW, can you teach me how did you get to the browser console of such an Android system browser. :-)

lannka avatar Nov 02 '16 23:11 lannka

I'm sure our CSS experts can get the desired result to work on older Androids.

On Wed, Nov 2, 2016 at 4:07 PM, Hongfei Ding [email protected] wrote:

So it's this piece of code? Do you know which one is badly supported?

const container = global.document.querySelector('#c'); container.style.top = '50%'; container.style.left = '50%'; container.style.bottom = ''; container.style.right = ''; container.style.transform = 'translate(-50%, -50%)';

BTW, can you teach me how did you get to the browser console of such an Android system browser. :-)

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

cramforce avatar Nov 02 '16 23:11 cramforce

@lannka That's the right piece of code. I don't have a comprehensive list of systems where this is broken, as I only tested on Android.

To test my changes I ran an Android instance through: /google/data/ro/teams/mobile_eng_prod/crow/crow.par

I also had to make some modifications for how script source URLs are generated, which you can find on my test branch here: https://github.com/google/amphtml/tree/ad-shift. Afterward I could use my machine's FQDN to hit my local gulp server through the Android instance.

@cramforce I will try to fix the CSS for Android, but if someone more knowledgeable in CSS wants to give me some pointers, that would be great.

glevitzky avatar Nov 03 '16 14:11 glevitzky

Someone with more experience with CSS please correct me if I'm wrong.

It seems like the issue is that CSS 'transform' property is not supported by Chrome versions 31 and below (the Android system web browser is apparently built on top of Chrome 30 according to useragent data), nor is it supported by Safari version 8 or below. Source: http://www.w3schools.com/cssref/css3_pr_transform.asp.

If that's the case, then the best bet is to find some alternative CSS that is supported in those versions, or, failing that, to carve out those older browser versions. For the latter, the worst case scenario would be creatives not being centered within multi-size ads, which currently are a very small fraction of total ads.

glevitzky avatar Nov 03 '16 14:11 glevitzky

Great investigation.

It sounds reasonable to fail for older browser if no good CSS alternative available.

lannka avatar Nov 03 '16 16:11 lannka

So, just add container.style.transform = container.style.webkitTransform = 'translate(-50%, -50%)'; ?

cramforce avatar Nov 03 '16 17:11 cramforce

That appears to work, at least for Android. Will confirm and put out a PR shortly.

glevitzky avatar Nov 03 '16 18:11 glevitzky

There's going to be other places affected by this. We should make a centerInParent helper function.

jridgewell avatar Nov 03 '16 18:11 jridgewell