How does this relate to XHR? Is this a higher-level idea or a
lower-level one? If it's higher-level, presumably we might later
expose a "xhr.ignoresResponse = true" flag?
In any case, this explains <a ping> which fits with the goal of a
layered platform.
In addition to the other suggestions in this thread, have you looked at programmatically creating an anchor element with a ping attribute and then synthesizing a click event on it? Does that work equally well?
Second question: Our implementation of <a ping> does nothing to ensure that the network request completes if the browser is meanwhile shutting down. Should it? Should Beacon API?
On Wed, Apr 16, 2014 at 10:40 PM, Darin Fisher <da...@chromium.org> wrote:
In addition to the other suggestions in this thread, have you looked at programmatically creating an anchor element with a ping attribute and then synthesizing a click event on it? Does that work equally well?
You could do something along those lines. But I see at least two problems with that -- the page would have to go to extra lengths to encode the different kinds of data that sendBeacon() supports in that ping URL (e.g., FormData, ArrayBufferView, arbitrary string.) And scripts would have to create <a ping> elements and dispatch events during unload (where sendBeacon()'s main use case lies) to achieve this. Doesn't sound entirely ideal.
Second question: Our implementation of <a ping> does nothing to ensure that the network request completes if the browser is meanwhile shutting down. Should it? Should Beacon API?Good question. The Beacon spec says the UA should make a "best effort" to send the beacon. There are no guarantees of delivery. The HTML spec makes no mention of this issue, afaict.
--sigbjorn
--sigbjorn
I agree that Beacon API is easier to use. I think my question gets to the motivation for Beacon API.Is it that web developers do not understand that they can use <a ping> in this way that they do not? Or, do we know that they do not? You didn't mention <a ping> in the motivation section.
Is Beacon API purely syntactic sugar over existing functionality? Can it be polyfilled on top of existing functionality?
On Wed, Apr 16, 2014 at 2:40 PM, Darin Fisher <da...@chromium.org> wrote:
I agree that Beacon API is easier to use. I think my question gets to the motivation for Beacon API.Is it that web developers do not understand that they can use <a ping> in this way that they do not? Or, do we know that they do not? You didn't mention <a ping> in the motivation section.<a ping> does not allow me to POST data, which is one of the primary use cases for a lot of analytics reporting.
Is Beacon API purely syntactic sugar over existing functionality? Can it be polyfilled on top of existing functionality?I don't believe so. There was a lengthy discussion on this topic on public-web-perf and between all the various hacks (images, sync xhrs, etc), none could fulfill all of the criteria. Further, from experience we know that even with current "state of art" methods, there is significant beacon loss (anecdotally ~30% from various sites). The goal of Beacon is to provide a simple API (that actually works) and much better delivery rate.
On Wed, Apr 16, 2014 at 4:03 PM, Ilya Grigorik <igri...@google.com> wrote:
On Wed, Apr 16, 2014 at 2:40 PM, Darin Fisher <da...@chromium.org> wrote:
I agree that Beacon API is easier to use. I think my question gets to the motivation for Beacon API.Is it that web developers do not understand that they can use <a ping> in this way that they do not? Or, do we know that they do not? You didn't mention <a ping> in the motivation section.<a ping> does not allow me to POST data, which is one of the primary use cases for a lot of analytics reporting.
Right, you need to encode it in the URL. Are you saying the ability to construct a POST request is the only feature missing from the existing platform? (IMG and <a ping> requires you to encode the information in the URL.)
On Wed, Apr 16, 2014 at 4:18 PM, Darin Fisher <da...@chromium.org> wrote:On Wed, Apr 16, 2014 at 4:03 PM, Ilya Grigorik <igri...@google.com> wrote:
On Wed, Apr 16, 2014 at 2:40 PM, Darin Fisher <da...@chromium.org> wrote:
I agree that Beacon API is easier to use. I think my question gets to the motivation for Beacon API.Is it that web developers do not understand that they can use <a ping> in this way that they do not? Or, do we know that they do not? You didn't mention <a ping> in the motivation section.<a ping> does not allow me to POST data, which is one of the primary use cases for a lot of analytics reporting.
Right, you need to encode it in the URL. Are you saying the ability to construct a POST request is the only feature missing from the existing platform? (IMG and <a ping> requires you to encode the information in the URL.)We need a reliable mechanism to upload arbitrary payloads without blocking the UA and being cancelled across navigations.- Semantically, POSTing data is the right mechanism.- Encoding data in a URL places hard limits on size of payload (that, and that's not what URLs are for...)A bit of background...In the early stages of the discussion I reached out to go Google Analytics team to see how they solve this problem today. Answer: sync XHRs and payloads of up to 10KB (this is already outside of URL-encoding reach). When we proposed adding a 10KB limit on uploads to ensure that these beacons don't interfere with next navigation (something that IE team was worried about), others piped up citing examples where they have uploads in 20KB+ territory (e.g. error reports with stack traces). As a result, the decision was to omit specifying a payload limit in v1, but reserve the right to add it in the future version of the spec (pending real world experience).
Reliability of delivery was the other big concern. The language in the spec is intentionally loose: the consensus was that without implementation experience we can't provide any specific guarantees, but that the UA *can* (read should/will) go the extra mile to ensure that the beacon is delivered. This may mean postponing it, retrying delivery, etc. Once again, this could be a UA specific strategy, or if some universal pattern emerges later, we can update the spec to include that... In my books, if Beacon does not improve delivery rate, then Beacon has failed.
There was also a round of discussions around aggregating Beacons which would allow the UA to batch / delay multiple beacon requests and fire them off at once to avoid waking the radio on each one. However, to keep things simple, that was omitted (for now?).I think the collection of all of the above is why the conclusion was to define Beacon as a standalone API as opposed to decorating XHR with an extra "ignoreResponse" flag. If you omit all payload limits, skip the retries / improving delivery, eliminate aggregation then yeah, XHR flag would do the trick, but it also doesn't give us much wiggle room. In short, I think Beacon is sufficiently different based on above requirements that a standalone API is a reasonable approach.
I'd strongly caution against further hacks that require programmatic driving of the declarative API to get things done. It's antithetical to layering. I support this API as a targeted intervention that can, in future, in turn be explained by a series of XHR or fetch() flags.
LGTM
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
Yeah, I really like the idea of the UA getting to know that the web developer is trying to send a beacon.
OK, I'm convinced. Beacon API sounds good to me.Implementation note: In Chromium, "beacons" are currently issued to the browser process a network requests of type ResourceType::PING. This is used for <a ping>, images started during unload, and I think it should also be used by Beacon API. We should then explore how to make ResourceType::PING more reliable. If we don't do the latter, then I don't think anyone will be happy using Beacon API.
-Darin
I'm glad that the beacon spec allows UA to do size caps when calling sendBeacon, particularly if we plan to persist these across restarts.However, there's no specified cap in the spec. I worry that developers are going to have reverse-engineer sizes provided by the UAs, especially since truncation is not handled under the hood. Are there plans to make this more clear?
On Thu, Apr 17, 2014 at 12:27 PM, Chris Bentzel <cben...@chromium.org> wrote:I'm glad that the beacon spec allows UA to do size caps when calling sendBeacon, particularly if we plan to persist these across restarts.However, there's no specified cap in the spec. I worry that developers are going to have reverse-engineer sizes provided by the UAs, especially since truncation is not handled under the hood. Are there plans to make this more clear?"If the User Agent limits the amount of data that can be queued to be sent using this API and the size of data causes that limit to be exceeded, this method returns false."The decision as to what makes a reasonable cutoff is deferred to the UA. In theory this also allows the UA to adapt / change the cutoff based on environment conditions - e.g. spotty connection or user on a roaming ($$$) plan, etc. That said, I'd expect that most UAs would converge on some ~common defaults.
On Thu, Apr 17, 2014 at 12:51 PM, William Chan (陈智昌) <will...@chromium.org> wrote:
On Wed, Apr 16, 2014 at 9:07 PM, Darin Fisher <da...@chromium.org> wrote:Right! My point is that we could make that change to the current backend without any API changes. The issue of beacon reliability is completely orthogonal to the API used to construct the beacon. Just want to make sure we focus on why the new API matters. It doesn't have anything to do with beacon reliability.Did anyone address Darin's point here? I agree with Darin's analysis on the orthogonal nature of API and beacon reliability. If the beacon API authors believe otherwise, it'd be very useful to hear why.I think so? We should make both <a ping> and Beacon more reliable.
I think so? We should make both <a ping> and Beacon more reliable.And, image loaded from unload? I see no reason to leave that out since people already use it. (It would be more work to make it different.)
Folks use the IMG trick in IE, going way back to older versions. The other APIs aren't available in IE.
Maybe a compromise is that we should only talk about Beacon then ;-)