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

✨ add ads: baidu #19489

Merged
merged 11 commits into from
Dec 7, 2018
Merged

✨ add ads: baidu #19489

merged 11 commits into from
Dec 7, 2018

Conversation

PengXing
Copy link
Contributor

Ad an ads: baidu.

Baidu is an advertising provider in China, and it plays an important role.

@PengXing
Copy link
Contributor Author

The limitation of bundlesize of v0.js is so strict. I don't know what I can do now. Maybe I should @choumx and @jridgewell.

[08:59:33] FAIL  ./dist/v0.js: 83.23KB > maxSize 83.2KB (gzip)
[08:59:33] ERROR: bundlesize found that ./dist/v0.js has exceeded its size cap of 83.2KB (Δ +0.03KB)
[08:59:33] This is part of a new effort to reduce AMP's binary size (#14392).
[08:59:33] Please contact @choumx or @jridgewell for assistance.

@dreamofabear dreamofabear requested a review from lannka November 28, 2018 15:39
@dreamofabear
Copy link

This PR shouldn't affect the size of v0.js. This may be related:

[08:59:33] Branch point from master is fa99cee
[08:59:33] WARNING: Failed to retrieve bundle size of fa99cee
[08:59:33] Falling back to comparing to the max bundle size only

I restarted the build for you. @danielrozenberg FYI.

@dreamofabear
Copy link

/to @lannka

@danielrozenberg
Copy link
Member

Re bundle-size - the base commit on master failed to store the new bundle size because, ironically, it increased the bundle size and failed. This isn't how gulp bundle-size should behave when executed on a master commit (it shouldn't reject the build, it should still store it) but since this is a rare case and I'm already working on changing the behaviour of bundle size checks (#19146,) we'll have to skip this one.

To unblock you we're increasing the max bundle size (ampproject/amphtml-build-artifacts#7), and will manually re-trigger Travis builds on the master branch to create files to store those base sizes for each of the commits that failed so far. Once that's done, we can re-trigger Travis here and it should pass. This should take about ~1-2 hours. Apologies for the hassle!

@danielrozenberg
Copy link
Member

Update: bundle-size now passes, but your PR fails on validator tests. PTAL

ads/_config.js Outdated
@@ -202,6 +202,10 @@ export const adConfig = {
],
},

'baidu': {
prefetch: 'https://dup.baidustatic.com/js/dm.js',
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please implement the render-start API?

full guideline

@PengXing
Copy link
Contributor Author

PengXing commented Nov 29, 2018

@lannka The renderStart and noContentAvailable API have been implemented in the latest commit. You may check it.
@danielrozenberg The ads.out file has been regenerated by running the gulp validator --update-tests.

global.context.renderStart();
},
() => {
global.context.noContentAvailable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only gets called when the script is failed to load.

does dm.js script fire global events when ad response is back? that will be the time to call renderStart or noContentAvailable, depending on if the ad is filled or not.

@PengXing
Copy link
Contributor Author

PengXing commented Nov 30, 2018

It would be better, but for now, dm.js doesn't fire global events when ad response is back. I have adjusted the timing of invoking renderStart instead of global events, see ef71a8b. The inner ad iframe will post a message to parent iframe once the inner page loaded.

I made this change 85fd9ca with the reference of the source code of directadvert.js.

@lannka
Copy link
Contributor

lannka commented Nov 30, 2018

does the message tell parent if the ad request returns an ad or not? noContentAvailable should be called when the response is empty.

@PengXing
Copy link
Contributor Author

PengXing commented Nov 30, 2018

Yes, the ad content is in the page. It exists as a JSON, and will be written in the page by JS immediately. The message is a sign of successful loading, no message, no ad. But I don't know how to prevent the disappearance of default AMP ad loading mask until message received.

var ad = [
  {
    "surl" : "gongyi.baidu.com",
    "isHb" : "true",
    "bid" : "",
    "res" : "http://ubmcmm.baidustatic.com/media/v1/0f000F_LSb3bh3jmLIlBS6.png",
    "width" : 728,
    "height" : 90,
    "type" : "image",
  }
];

@lannka
Copy link
Contributor

lannka commented Nov 30, 2018

Got you, seems tricky then. Would you add a comment to explain that there is no good way to do noContentAvailable call.

Otherwise the PR looks good to me. Thanks!

@PengXing
Copy link
Contributor Author

PengXing commented Dec 1, 2018

noContentAvailable should be called if parent iframe receives no message. I can use setTimeout, but it's not that reliable, due to complicated and unstable network conditions. So, there is no good way to do perfect noContentAvailable call.

@lannka
Copy link
Contributor

lannka commented Dec 3, 2018

Thanks @PengXing . I meant to have that as JS comment in the code to inform other developers.

@PengXing
Copy link
Contributor Author

PengXing commented Dec 4, 2018

@lannka Please see da772ce.

Copy link
Contributor

@lannka lannka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will want to merge with "master head" to resolve the failing travis test.

@@ -492,5 +492,11 @@ <h2>PulsePoint 300x250</h2>
data-size="300X250">
</amp-ad>

<h2>Baidu</h2>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed. this is a legacy file that is deprecated

@@ -250,6 +250,7 @@ import {zedo} from '../ads/zedo';
import {zen} from '../ads/zen';
import {zergnet} from '../ads/zergnet';
import {zucks} from '../ads/zucks';
import {baidu} from '../ads/baidu';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetical order pls

@@ -479,6 +480,7 @@ register('zedo', zedo);
register('zen', zen);
register('zergnet', zergnet);
register('zucks', zucks);
register('baidu', baidu);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetical order

@@ -1336,5 +1337,11 @@ <h2>Zucks</h2>
type="zucks"
data-frame-id="_bda46cf5ac">
</amp-ad>

<h2>Baidu</h2>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetical order pls

@@ -235,6 +235,7 @@
<option>zen</option>
<option>zergnet</option>
<option>zucks</option>
<option>badiu</option>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more here

@@ -1911,5 +1912,11 @@ <h2>Zucks</h2>
data-frame-id="_bda46cf5ac">
</amp-ad>

<h2>Baidu</h2>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

delete preconnect, as it has the same domain with prefetch url
The new `ads.out` is regenerated by running `gulp validator --update-tests`.
Add JS comment to explain why there is no good way to do `noContentAvailable` call.
1. rearrage the code
2. regenerate ads.out
@PengXing
Copy link
Contributor Author

PengXing commented Dec 6, 2018

I have completed the modification of all alphabetical order problems. Please check it.

The Travis CI build failed caused by failure of dead link check. And the link of baidu ad union website is not dead. Maybe the Travis CI build should be re-run.

> [ LinkCheckResult {
    link: 'http://union.baidu.com/product/prod-cpro.html',
    statusCode: 200,
    err: null,
    status: 'alive' } ]

@lannka lannka merged commit 384cf61 into ampproject:master Dec 7, 2018
@lannka
Copy link
Contributor

lannka commented Dec 7, 2018

Tests passed. Merged.

@PengXing
Copy link
Contributor Author

PengXing commented Dec 8, 2018

Thanks a lot.

noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* ✨ add ads: baidu

* fix lint errors

* delete preconnect

delete preconnect, as it has the same domain with prefetch url

* Update validator test: ads.out

The new `ads.out` is regenerated by running `gulp validator --update-tests`.

* Implelmentation of renderStart and noContentAvaliable API

Following the guidance of this documentation, [ads README.md](https://github.com/ampproject/amphtml/blob/master/ads/README.md)

* fix lint errors.

* Adjust the timing of invoking renderStart

* Add JS comment

Add JS comment to explain why there is no good way to do `noContentAvailable` call.

* Rearrage the code in alphabetical order

1. rearrage the code
2. regenerate ads.out

* Modify a missing alphabetical order problem

* Modify a missing alphabetical order problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants