Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Issue 1968933002: Fix: tabs slow to response to beforeunload are closed prematurely. (Closed)

Created:
4 years, 7 months ago by Mikhail Goncharov
Modified:
4 years, 7 months ago
Reviewers:
clamy, Charlie Reis, sky
CC:
chromium-reviews, darin-cc_chromium.org, nasko+codewatch_chromium.org, jam, creis+watch_chromium.org, Avi (use Gerrit)
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix: tabs slow to response to beforeunload are closed prematurely. Issue mitigates as browser loses some tabs after relaunch. What happens underneath in time order: - browser initiates shutdown and asks unload controller to fire beforeunload events - unload controller fills up queue of tabs to notify and fires beforeunload to tab #1 - frame host proxies event to tab #1 and starts one second timer - tab #1 receives beforeunload and starts processing - timer expires and web_content_impl receives RendererUnresponsive. It fires onbeforeunloadACK on behalf of tab #1 - unload controller receives ACK; finds tab #1 in beforeunload queue, removes it from that queue and put to the queue "unload", responses with 'false' (aka "don't unload") as we want to fire unload events when every tab accepted unload. Now unload controller fires beforeunload to tab #2 - frame host proxies event to tab #2 and starts one second timer - tab #1 has finished and fires beforeunload ACK (it was slow to respond because of system load or trip to server or w/e) - unload controller receives ACK; is unable to find tab #1 in queue (tab was already removed), assumes that tab #1 was created after queue was formed and responds with 'true' ("proceed unload") - tab #1 unloads and notifies session service (session service is still alive atm) - session service records that tab #1 was closed. That's it. Now chrome will not restore this tab. Same thing may happen to some other tabs. Missed tabs will be scattered randomly across tabstrips depending on OS schedule and content. Intend of this CL is to prevent such scenarios. Responsiveness of browser should not be changed - even if tab is really unresponsive it will be closed as before, after unload controller made sure that every other tab is acknowledged unload. New tests might be flacky like TestHangInBeforeUnloadMultipleTabs because under heavy load tab might fail to response within one second and treated as if it has no beforeunload handler. BUG=365052 R=clamy@chromium.org,sky@chromium.org CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation Committed: https://crrev.com/73fc9555a1ecb23f1076b51e4602dfee5419e2f9 Cr-Commit-Position: refs/heads/master@{#395368}

Patch Set 1 : Draft #

Patch Set 2 : Revisited solution #

Total comments: 6

Patch Set 3 : Use whole rfhi::BeforeUnloadAck #

Total comments: 15

Patch Set 4 : Review fixes; new tests are disabled #

Patch Set 5 : with tests completely disabled #

Patch Set 6 : Correct order of checks #

Unified diffs Side-by-side diffs Delta from patch set Stats (+142 lines, -14 lines) Patch
M chrome/browser/lifetime/browser_close_manager_browsertest.cc View 1 2 3 4 1 chunk +99 lines, -0 lines 0 comments Download
A chrome/test/data/beforeunload_slow.html View 1 2 3 1 chunk +19 lines, -0 lines 0 comments Download
M content/browser/frame_host/render_frame_host_impl.h View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M content/browser/frame_host/render_frame_host_impl.cc View 1 2 3 1 chunk +6 lines, -0 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 2 3 4 5 1 chunk +15 lines, -14 lines 0 comments Download

Messages

Total messages: 58 (18 generated)
Mikhail Goncharov
4 years, 7 months ago (2016-05-11 10:42:54 UTC) #1
Charlie Reis
We should not do this. Wouldn't it mean that you couldn't close a tab if ...
4 years, 7 months ago (2016-05-11 17:10:17 UTC) #4
Mikhail Goncharov
On 2016/05/11 17:10:17, Charlie Reis wrote: > We should not do this. Wouldn't it mean ...
4 years, 7 months ago (2016-05-12 06:09:01 UTC) #5
clamy
On 2016/05/12 06:09:01, metaflow wrote: > On 2016/05/11 17:10:17, Charlie Reis wrote: > > We ...
4 years, 7 months ago (2016-05-12 06:26:11 UTC) #6
Mikhail Goncharov
On 2016/05/12 06:26:11, clamy wrote: > On 2016/05/12 06:09:01, metaflow wrote: > > On 2016/05/11 ...
4 years, 7 months ago (2016-05-12 06:52:11 UTC) #7
clamy
On 2016/05/12 06:52:11, metaflow wrote: > On 2016/05/12 06:26:11, clamy wrote: > > On 2016/05/12 ...
4 years, 7 months ago (2016-05-12 07:24:31 UTC) #8
Mikhail Goncharov
On 2016/05/12 07:24:31, clamy wrote: > On 2016/05/12 06:52:11, metaflow wrote: > > On 2016/05/12 ...
4 years, 7 months ago (2016-05-12 08:10:32 UTC) #9
Charlie Reis
[+sky] Wow, thanks for explaining! That didn't come across in the CL description. Can you ...
4 years, 7 months ago (2016-05-12 17:03:41 UTC) #11
Mikhail Goncharov
I have uploaded revisited solution: - turns out it is enough to tell render_frame_host_impl to ...
4 years, 7 months ago (2016-05-12 17:11:31 UTC) #12
Mikhail Goncharov
On 2016/05/12 17:03:41, Charlie Reis wrote: > [+sky] > > Wow, thanks for explaining! That ...
4 years, 7 months ago (2016-05-12 17:17:13 UTC) #13
Mikhail Goncharov
On 2016/05/12 17:11:31, Mikhail Goncharov wrote: > I have uploaded revisited solution: > > - ...
4 years, 7 months ago (2016-05-12 17:18:14 UTC) #14
Mikhail Goncharov
On 2016/05/12 17:17:13, Mikhail Goncharov wrote: > On 2016/05/12 17:03:41, Charlie Reis wrote: > > ...
4 years, 7 months ago (2016-05-12 17:21:42 UTC) #15
Charlie Reis
On 2016/05/12 17:18:14, Mikhail Goncharov wrote: > On 2016/05/12 17:11:31, Mikhail Goncharov wrote: > > ...
4 years, 7 months ago (2016-05-12 18:40:56 UTC) #17
Charlie Reis
sky@, can you see if you have any recommendations for how to write a non-flaky ...
4 years, 7 months ago (2016-05-13 22:24:01 UTC) #18
sky
On 2016/05/13 22:24:01, Charlie Reis (slow to reply) wrote: > sky@, can you see if ...
4 years, 7 months ago (2016-05-13 23:38:03 UTC) #19
Mikhail Goncharov
https://codereview.chromium.org/1968933002/diff/20001/chrome/browser/lifetime/browser_close_manager_browsertest.cc File chrome/browser/lifetime/browser_close_manager_browsertest.cc (right): https://codereview.chromium.org/1968933002/diff/20001/chrome/browser/lifetime/browser_close_manager_browsertest.cc#newcode520 chrome/browser/lifetime/browser_close_manager_browsertest.cc:520: TestBeforeUnloadMultipleSlowWindows) { On 2016/05/13 22:24:01, Charlie Reis (slow to ...
4 years, 7 months ago (2016-05-16 04:50:40 UTC) #20
Mikhail Goncharov
https://codereview.chromium.org/1968933002/diff/20001/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/1968933002/diff/20001/content/browser/web_contents/web_contents_impl.cc#newcode4576 content/browser/web_contents/web_contents_impl.cc:4576: rfhi->DontWaitForBeforeUnloadAck(); On 2016/05/13 22:24:01, Charlie Reis (slow to reply) ...
4 years, 7 months ago (2016-05-16 05:02:01 UTC) #21
Mikhail Goncharov
https://codereview.chromium.org/1968933002/diff/20001/chrome/browser/lifetime/browser_close_manager_browsertest.cc File chrome/browser/lifetime/browser_close_manager_browsertest.cc (right): https://codereview.chromium.org/1968933002/diff/20001/chrome/browser/lifetime/browser_close_manager_browsertest.cc#newcode486 chrome/browser/lifetime/browser_close_manager_browsertest.cc:486: for (int i = 0; i < 7; i++) ...
4 years, 7 months ago (2016-05-16 06:10:31 UTC) #22
Mikhail Goncharov
On 2016/05/13 23:38:03, sky wrote: > On 2016/05/13 22:24:01, Charlie Reis (slow to reply) wrote: ...
4 years, 7 months ago (2016-05-16 06:17:37 UTC) #23
sky
On Sun, May 15, 2016 at 11:17 PM, <metaflow@yandex-team.ru> wrote: > On 2016/05/13 23:38:03, sky ...
4 years, 7 months ago (2016-05-16 18:04:14 UTC) #24
Charlie Reis
Ok, I've patched in the CL locally to better understand the flakiness, and it makes ...
4 years, 7 months ago (2016-05-19 22:11:56 UTC) #25
Charlie Reis
On 2016/05/19 22:11:56, Charlie Reis (slow to reply) wrote: > I suggest that we proceed ...
4 years, 7 months ago (2016-05-20 01:12:22 UTC) #26
Mikhail Goncharov
https://codereview.chromium.org/1968933002/diff/40001/chrome/browser/lifetime/browser_close_manager_browsertest.cc File chrome/browser/lifetime/browser_close_manager_browsertest.cc (right): https://codereview.chromium.org/1968933002/diff/40001/chrome/browser/lifetime/browser_close_manager_browsertest.cc#newcode506 chrome/browser/lifetime/browser_close_manager_browsertest.cc:506: ASSERT_NO_FATAL_FAILURE(CancelClose()); On 2016/05/19 22:11:55, Charlie Reis (slow to reply) ...
4 years, 7 months ago (2016-05-20 04:20:01 UTC) #27
Charlie Reis
On 2016/05/20 04:20:01, Mikhail Goncharov wrote: > https://codereview.chromium.org/1968933002/diff/40001/chrome/browser/lifetime/browser_close_manager_browsertest.cc > File chrome/browser/lifetime/browser_close_manager_browsertest.cc (right): > > https://codereview.chromium.org/1968933002/diff/40001/chrome/browser/lifetime/browser_close_manager_browsertest.cc#newcode506 ...
4 years, 7 months ago (2016-05-20 04:42:10 UTC) #28
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1968933002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1968933002/80001
4 years, 7 months ago (2016-05-20 10:06:12 UTC) #34
commit-bot: I haz the power
No L-G-T-M from a valid reviewer yet. CQ run can only be started by full ...
4 years, 7 months ago (2016-05-20 10:06:15 UTC) #36
Charlie Reis
LGTM if the try bots are happy. sky@, can you review chrome/ for OWNERS? We're ...
4 years, 7 months ago (2016-05-20 16:24:37 UTC) #37
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1968933002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1968933002/80001
4 years, 7 months ago (2016-05-20 16:24:53 UTC) #39
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_ozone_rel_ng/builds/173871)
4 years, 7 months ago (2016-05-20 16:46:58 UTC) #41
Charlie Reis
Mikhail, can you take look at the failure in the RenderFrameHostManagerTest.CloseWithPendingWhileUnresponsive unit test?
4 years, 7 months ago (2016-05-20 16:50:18 UTC) #42
sky
LGTM
4 years, 7 months ago (2016-05-20 19:18:25 UTC) #43
Mikhail Goncharov
On 2016/05/20 16:50:18, Charlie Reis (slow to reply) wrote: > Mikhail, can you take look ...
4 years, 7 months ago (2016-05-21 08:34:37 UTC) #44
Mikhail Goncharov
On 2016/05/21 08:34:37, Mikhail Goncharov wrote: > On 2016/05/20 16:50:18, Charlie Reis (slow to reply) ...
4 years, 7 months ago (2016-05-21 09:32:24 UTC) #45
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1968933002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1968933002/100001
4 years, 7 months ago (2016-05-21 09:33:20 UTC) #47
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 7 months ago (2016-05-21 10:45:45 UTC) #49
Mikhail Goncharov
> Let's keep this CL as the fix plus the disabled test. In a followup ...
4 years, 7 months ago (2016-05-21 15:46:16 UTC) #50
Charlie Reis
Thanks for the fix! LGTM.
4 years, 7 months ago (2016-05-23 16:36:33 UTC) #51
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1968933002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1968933002/100001
4 years, 7 months ago (2016-05-23 16:36:57 UTC) #54
commit-bot: I haz the power
Committed patchset #6 (id:100001)
4 years, 7 months ago (2016-05-23 18:27:00 UTC) #56
commit-bot: I haz the power
4 years, 7 months ago (2016-05-23 18:29:47 UTC) #58
Message was sent while issue was closed.
Patchset 6 (id:??) landed as
https://crrev.com/73fc9555a1ecb23f1076b51e4602dfee5419e2f9
Cr-Commit-Position: refs/heads/master@{#395368}

Powered by Google App Engine
This is Rietveld 408576698