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

FF Ads Reporgin - iframe support in FOT? #309

Closed
jonasz opened this issue Jun 1, 2022 · 17 comments
Closed

FF Ads Reporgin - iframe support in FOT? #309

jonasz opened this issue Jun 1, 2022 · 17 comments

Comments

@jonasz
Copy link
Contributor

jonasz commented Jun 1, 2022

Hi,

As we are working on analyzing FLEDGE performance during the first Origin Trial, we are looking for a way to identify which ad impressions resulted in a click. (Effectively - "we've gotten a call from reportWin, was there a click event later on?".)

Longer term we are planning to rely on Fenced Frames Ads Reporting ("FFAR") to satisfy this use case.

In FOT1, however, ads are rendered in iframes, and it seems FFAR is not available there. I was wondering, would it be possible to enable it, temporarily, in iframes as well? (Despite the "FF" in the name :) )

Best regards,
Jonasz

@JensenPaul
Copy link
Collaborator

@shivanigithub might know if this is possible

@shivanigithub
Copy link
Contributor

Yes, window.fence.reportEvent is only available inside opaque-ads mode fenced frames currently.
I think temporarily allowing it in an iframe that was created using a urn:uuid mapped url should be fine. Let me check with the team and update back here.

@gtanzer
Copy link
Contributor

gtanzer commented Jun 6, 2022

@jonasz Should be doable. We have a mostly done CL for it here: https://chromium-review.googlesource.com/c/chromium/src/+/3690741

For implementation convenience, window.fence.reportEvent would only work when invoked from the iframe that was actually navigated to a urn:uuid (the equivalent of the fenced frame root). I hope/imagine that should be fine as a temporary solution. There's some elaboration in the CL description.

The behavior is the same within fenced frames.

@jonasz
Copy link
Contributor Author

jonasz commented Jun 10, 2022

Thank you all for the quick response!

For implementation convenience, window.fence.reportEvent would only work when invoked from the iframe that was actually navigated to a urn:uuid (the equivalent of the fenced frame root).

Note that as a buyer (DSP), we do not always control how the iframes are created on the publisher's site. I will confirm with our SSP partners if using an URN works for them, and will let you know as soon as I have an answer.

aarongable pushed a commit to chromium/chromium that referenced this issue Jun 15, 2022
Associated with the FLEDGE origin trial, there is a flag that allows iframes to load urn:uuids. This CL also enables window.fence.reportEvent in that case, to make it easier to test the new APIs. This will be removed when the iframe urn:uuid flag is removed.

For implementation reasons, the behavior right now is:
- If the invoking frame is in a fenced frame tree, the behavior is the same as before.
- If the invoking frame isn't in a fenced frame tree, reportEvent is available only when the invoking frame is an iframe whose document was navigated to a urn:uuid with attached reporting metadata.

For some examples:

* embedder > iframe1 (urn1) > iframe2 (https)
  fence.reportEvent works from iframe1 only.
* embedder > iframe1 (urn1) > iframe2 (urn2)
  fence.reportEvent works from iframe1 (to urn1) and iframe2 (to urn2)
* embedder > fencedframe1 (urn1) > iframe2 (https)
  fence.reportEvent works from fencedframe1 and iframe2 (both to urn1)
* embedder > fencedframe1 (urn1) > iframe2 (urn2)
  fence.reportEvent works from fencedframe1 and iframe2 (BOTH to urn1)

WICG/turtledove#309

Change-Id: Ie85bfb5264eb1ae78769533b2b8939f3168c8656
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3690741
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Arthur Sonzogni <[email protected]>
Reviewed-by: Shivani Sharma <[email protected]>
Commit-Queue: Garrett Tanzer <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1014688}
@jonasz
Copy link
Contributor Author

jonasz commented Jun 16, 2022

Hi, just wanted to circle back to confirm that we will indeed work with URN-based iframes. I hope using deprecatedReplaceInURN doesn't break the functionality.

I was wondering, is there any chance this change will be deployed (cherry picked?) to the beta channel sometime soon?

@gtanzer
Copy link
Contributor

gtanzer commented Jun 17, 2022

It should be fine to use deprecateReplaceInURN; it looks like it just overwrites the relevant fields and copies the rest of the mapping over:
https://source.chromium.org/chromium/chromium/src/+/main:content/browser/fenced_frame/fenced_frame_url_mapping.cc;l=315

We're working on getting it into M104 Beta on June 23.
https://bugs.chromium.org/p/chromium/issues/detail?id=1337323

@gtanzer
Copy link
Contributor

gtanzer commented Jun 24, 2022

It got merged into the M104 (Beta) branch today. So it should be live in Beta in the next update (within a week), but I'm not sure of the exact release schedule.
https://chromium-review.googlesource.com/c/chromium/src/+/3721476

@jonasz
Copy link
Contributor Author

jonasz commented Jun 27, 2022

Great to hear, thanks!

@jonasz jonasz closed this as completed Jun 27, 2022
darinwf pushed a commit to neevaco/chromium that referenced this issue Aug 10, 2022
…s cherrypick into M104

Associated with the FLEDGE origin trial, there is a flag that allows iframes to load urn:uuids. This CL also enables window.fence.reportEvent in that case, to make it easier to test the new APIs. This will be removed when the iframe urn:uuid flag is removed.

For implementation reasons, the behavior right now is:
- If the invoking frame is in a fenced frame tree, the behavior is the same as before.
- If the invoking frame isn't in a fenced frame tree, reportEvent is available only when the invoking frame is an iframe whose document was navigated to a urn:uuid with attached reporting metadata.

For some examples:

* embedder > iframe1 (urn1) > iframe2 (https)
  fence.reportEvent works from iframe1 only.
* embedder > iframe1 (urn1) > iframe2 (urn2)
  fence.reportEvent works from iframe1 (to urn1) and iframe2 (to urn2)
* embedder > fencedframe1 (urn1) > iframe2 (https)
  fence.reportEvent works from fencedframe1 and iframe2 (both to urn1)
* embedder > fencedframe1 (urn1) > iframe2 (urn2)
  fence.reportEvent works from fencedframe1 and iframe2 (BOTH to urn1)

WICG/turtledove#309

(cherry picked from commit 95b0232)

Change-Id: Ie85bfb5264eb1ae78769533b2b8939f3168c8656
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3690741
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Arthur Sonzogni <[email protected]>
Reviewed-by: Shivani Sharma <[email protected]>
Commit-Queue: Garrett Tanzer <[email protected]>
Cr-Original-Commit-Position: refs/heads/main@{#1014688}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3721476
Bot-Commit: Rubber Stamper <[email protected]>
Cr-Commit-Position: refs/branch-heads/5112@{chromium#262}
Cr-Branched-From: b13d3fe-refs/heads/main@{#1012729}
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
Associated with the FLEDGE origin trial, there is a flag that allows iframes to load urn:uuids. This CL also enables window.fence.reportEvent in that case, to make it easier to test the new APIs. This will be removed when the iframe urn:uuid flag is removed.

For implementation reasons, the behavior right now is:
- If the invoking frame is in a fenced frame tree, the behavior is the same as before.
- If the invoking frame isn't in a fenced frame tree, reportEvent is available only when the invoking frame is an iframe whose document was navigated to a urn:uuid with attached reporting metadata.

For some examples:

* embedder > iframe1 (urn1) > iframe2 (https)
  fence.reportEvent works from iframe1 only.
* embedder > iframe1 (urn1) > iframe2 (urn2)
  fence.reportEvent works from iframe1 (to urn1) and iframe2 (to urn2)
* embedder > fencedframe1 (urn1) > iframe2 (https)
  fence.reportEvent works from fencedframe1 and iframe2 (both to urn1)
* embedder > fencedframe1 (urn1) > iframe2 (urn2)
  fence.reportEvent works from fencedframe1 and iframe2 (BOTH to urn1)

WICG/turtledove#309

Change-Id: Ie85bfb5264eb1ae78769533b2b8939f3168c8656
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3690741
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Arthur Sonzogni <[email protected]>
Reviewed-by: Shivani Sharma <[email protected]>
Commit-Queue: Garrett Tanzer <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1014688}
NOKEYCHECK=True
GitOrigin-RevId: 95b0232d46b725c457f406db36de6461a9250e60
@fhoering
Copy link
Contributor

fhoering commented Jan 27, 2023

@gtanzer @shivanigithub
Sorry to comment on the closed ticket. We made some tests and the FF reporting API doesn't seem to be available from inside an iframe rendering. It works well from inside a fenced frame but not from inside an iframe where the window.fence property is not set.

We tried injecting the adUrn from the auction result directly into the iframe or calling deprecatedURNToURL before. Both renders but the window.fence property is not set.

 let adFrame = document.createElement('iframe');
 adFrame.src = adUrn;
 let url = await navigator.deprecatedURNToURL(adUrn)
 let adFrame = document.createElement('iframe');
 adFrame.src = url;

Can you a have a look if there is anything we are missing ?

It seems important to support the FF report APIs for both iframe and fenced frames because the buyer doesn't have any control on how the ad is rendered and some sellers might start of with iframe rendering and only then move to ff rendering.

@gtanzer
Copy link
Contributor

gtanzer commented Jan 27, 2023

Which Chrome version are you running? (not that there should be a problem with any version; just curious)

Also, are you definitely calling window.fence.reportEvent from the "root iframe" (i.e. the iframe that you navigated to the urn?)

@fhoering
Copy link
Contributor

fhoering commented Jan 27, 2023

I tested on the GAM test pages https://fledge-testing.uc.r.appspot.com/?nid=allow_all with latest Chrome 109.

Also, are you definitely calling window.fence.reportEvent from the "root iframe" (i.e. the iframe that you navigated to the urn?)

I don't call it from the root iframe because of the round trip to detect the ad size. So it is called in the child iframe. That is the reason then.
Is there something we can do about that ? I would expect this information to be propagated as it is done from inside the fenced frame.

@fhoering
Copy link
Contributor

If there is an API to retrieve the URN and propagate it to the child frame I can also do that.

@gtanzer
Copy link
Contributor

gtanzer commented Jan 27, 2023

I'm not sure I understand why the round trip to detect ad size motivates calling it in the child frame. I think reportEvent should currently work in the "root iframe" after same-origin navigations, but never in subframes of that frame.

We would like to support the API in all contexts where it makes sense; it's just an implementation issue. (The notion of a "urn iframe root" doesn't exist right now in the same way as "fenced frame root", but that can be fixed.) And it's been lower priority to support it in iframes, because you can just talk to the embedder if you really want to.

Until the size API changes (#417) are live, (or alternately until we finish some refactors that tidy up availability of APIs like reportEvent, e.g. https://chromium-review.googlesource.com/c/chromium/src/+/4086285), would it solve your problem to do the following?

  • Substitute the ad size into the urn using deprecatedReplaceInURN, so there is no need to wait to detect the ad size.

@fhoering
Copy link
Contributor

fhoering commented Jan 27, 2023

I'm not sure I understand why the round trip to detect ad size motivates calling it in the child frame. I think reportEvent should currently work in the "root iframe" after same-origin navigations, but never in subframes of that frame.

In theory it is possible for the display yes but it doesn't work for the click. They main motivation for implementing this is to measure clicks as the displays can already be measured by reportWin.

because you can just talk to the embedder if you really want to.

It would require seller/buyer cooperation because the embedder is the seller and the creative is displayed by the buyer. Not sure this is the way to go even if it stays temporary.

Substitute the ad size into the urn using deprecatedReplaceInURN, so there is no need to wait to detect the ad size.

It would have to be done by the seller. @sbelov Any input ? If possible it could be a workaround.

@gtanzer
Copy link
Contributor

gtanzer commented Feb 28, 2023

We made changes that I believe should fix this, for M112 (i.e. you can test it on Canary right now, or Beta once it releases on March 9).

I'm not sure that we have test cases for this exact situation (an iframe nested inside a urn iframe), but we do have tests separately for urn iframes and iframes nested inside fenced frames. Could you take a look at your tests and see if it's working now?

One detail is that reportEvent will only work in contexts that are same-origin to the mapped url in the urn. The intent here is to prevent other origins from sending unauthorized reports. Please let us know if this is a problem.

@fhoering
Copy link
Contributor

fhoering commented Mar 2, 2023

It looks fine in Chrome 112 Canary with urn iframes. Thanks for the fix.
The same origin restriction is not an issue as the events are registered on the same bidding and tagging origin.

@gtanzer
Copy link
Contributor

gtanzer commented Mar 2, 2023

Glad to hear that it's working for you.

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

No branches or pull requests

5 participants