New issue
Advanced search Search tips

Issue 882419 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

navigator.sendBeacon method doesn't work when used onbeforeunload

Reported by jakub.fr...@wingu.de, Sep 10

Issue description

Application Version (from "Chrome Settings > About Chrome"): 68.0.3440.91
Android Build Number (from "Android Settings > About Phone/Tablet"): OPM1.171019.026.V9.6.5.0.ODHMIFE
Device: Xiaomi Mi A1

Steps to reproduce: 
Open up a webpage with navigator.sendBeacon fired from onbeforeunload through chrome custom tab. Close the custom tab - request from navigator.sendBeacon haven't got to the end server (probably tab process was killed before sendBeacon finished sending request).

Observed behavior: 
When webpage is opened inside of e.g. nearby app and then is closed, navigator.sendBeacon method fired inside the onbeforeunload callback does not work. It seems that event callback gets called, but sendBeacon doesn't have enough time to fire request (and wait for response), so nothing comes to an endpoint.

Expected behavior: 
navigator.sendBeacon should work as described on MDN (https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon) & how it's working in current version of chrome browser. So, webview should fire sendBeacon method even when whole app is being closed/killed

Frequency: 
Always

Additional comments: 
To see that sendBeacon is not working there would be need to create custom webserver & client webpage & open it up in nearby app. Do you have maybe any template (guidance) how to create such example?

 
Components: Blink>Network
Components: UI>Browser>Mobile>CustomTabs
Adding UI>Browser>Mobile>CustomTabs. What happens when the user closes a custom tab?
Labels: Needs-triage-Mobile
yhriano@chromium.org is it question for me?
Well, tab closes, but it seems sendBeacon doesn't have time to fire. That's what I know - hard to debug it by myself - I'm not android developer. Don't know even where to start - should I create some test app with custom tabs? Will I have access then to the internal code of tab (in the best scenario also it will be nice to put breakpoint in onbeforeunload js handler).
Cc: peconn@chromium.org
Hi Jakub, can you reproduce this with plain Chrome instead of Custom Tabs?
Hi peconn,
With standalone chrome (both on desktop & mobile) everything works as expected. Or do you want me to check on some kind of in-app webview (is chrome used then)?
Ah, my question was for a Custom Tab expert.
Re #2, closing a Custom Tabs destroys the activity, not 100% sure what happens to the tab. Is there a requirement for the WebContents to be alive for a sendBeacon() to go through?
> #8

Basically, while the request initiated by sendBeacon is alive, we have the renderer alive (in the plain Chrome case). That is done by content::RenderProcessHost::IncrementKeepAliveRefCount and content::RenderProcessHost::DecrementKeepAliveRefCount. I'm not sure if/how they work with Chrome Custom Tabs.
bump?
(I'm waiting for lizeb@'s response)
With regards to creating a reproduction (you asked about in the end of #c1), there's no chance you've got a local build of Chrome for Android? Our tests have the ability to start up local servers, and writing a failing instrumentation test would be a pretty effective way of reproducing (although it is far more than what we would expect from you).
Owner: lizeb@chromium.org
Unfortunately I don't have local build of Chrome for Android on my machine (I'm specifically web dev) and won't have time for it at least for next month/two months (need to finish up my master thesis ;/)
Labels: Pri-2 Type-Bug
Status: Assigned (was: Unconfirmed)
Any possibility that this will be resolved soon? I can try to provide a github repo with failing app if that would help

Sign in to add a comment