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

Issue 647613002: Fix RenderWidgetHostViewGuest leak. (Closed)

Created:
6 years, 2 months ago by lazyboy
Modified:
6 years, 2 months ago
Reviewers:
sky, piman
CC:
chromium-reviews, creis+watch_chromium.org, yusukes+watch_chromium.org, yukishiino+watch_chromium.org, nasko+codewatch_chromium.org, jam, penghuang+watch_chromium.org, sievers+watch_chromium.org, jbauman+watch_chromium.org, nona+watch_chromium.org, darin-cc_chromium.org, kalyank, piman+watch_chromium.org, danakj+watch_chromium.org, James Su
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Fix RenderWidgetHostViewGuest leak. This used to happen on view initiated destruction, as opposed to RenderWidgetHostImpl initiated ones. In RWH initiated destruction, the views gets deleted properly. "View initiated destruction" means the view is first deleted before the host, this is aura's RWHViewAura::OnWindowDestroyed() or mac's ~RenderWidgetHostViewMac(). In view(V1) initiated destruction, RWH::SetView(NULL) call makes the host(H) drop the pointer to the view(V2) it's holding, in cases where the view initiated the destruction is not the view of the host(V1!=V2), it will leak V2. This scenario happens when there's an interstitial page showing inside <webview> guest. The platform RWHView gets deleted but the RWHViewGuest leaks as the RWH's view pointer is cleared while clearing the platform view. BUG=321662 Test=No visible change, internal change. To check leak sanitizer test, my steps are: gyp: CC=clang CXX=clang++ builddir_name=./tmp-llvm GYP_PARALLEL=1 \ PATH=$PWD/third_party/llvm-build/Release+Asserts/bin:$PATH \ GYP_GENERATORS='ninja' ./build/gyp_chromium -Gconfig=Release \ -Goutput_dir=out_asan_new -D"asan=1" -D"clang=1" \ -D"component=static_library" -D"lsan=1" -D"target_arch=x64" \ -D"use_allocator=none" build: PATH=$PWD/third_party/llvm-build/Release+Asserts/bin:$PATH \ ninja -C out_asan_new/Release -j 2048 browser_tests run: ASAN_OPTIONS="detect_leaks=1" \ LSAN_OPTIONS="suppressions=./tools/lsan/suppressions.txt" \ ./out_asan_new/Release/browser_tests \ --gtest_filter=WebViewTest.InterstitialTeardown \ --disable-seccomp-sandbox Committed: https://crrev.com/549b3b4f0cf5691d093823f285ffd437614af1f6 Cr-Commit-Position: refs/heads/master@{#300286}

Patch Set 1 #

Patch Set 2 : clean up for review #

Patch Set 3 : . #

Total comments: 1

Patch Set 4 : Add content_unittests #

Total comments: 2

Patch Set 5 : add comment for GetView() == this #

Patch Set 6 : add is_guest_view_hack_ to RWHV #

Total comments: 6

Patch Set 7 : remove is_guest_view_hack from CreateViewForPopupWidet #

Patch Set 8 : fix mac #

Patch Set 9 : fix aura test #

Patch Set 10 : add is_guest_view_hack_ check in rwhvmac-delegate call (needs review) #

Total comments: 3

Patch Set 11 : bring back mac delegate() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+212 lines, -67 lines) Patch
M chrome/browser/apps/web_view_browsertest.cc View 1 2 3 6 7 9 1 chunk +1 line, -7 lines 0 comments Download
M chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm View 1 2 3 4 5 6 7 8 9 10 1 chunk +6 lines, -2 lines 0 comments Download
M content/browser/browser_plugin/browser_plugin_guest.cc View 1 2 3 4 5 6 7 9 1 chunk +1 line, -1 line 0 comments Download
M content/browser/frame_host/interstitial_page_impl.cc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M content/browser/frame_host/render_widget_host_view_guest.h View 1 2 2 chunks +5 lines, -4 lines 0 comments Download
M content/browser/frame_host/render_widget_host_view_guest.cc View 1 3 chunks +4 lines, -3 lines 0 comments Download
M content/browser/frame_host/render_widget_host_view_guest_unittest.cc View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/renderer_host/DEPS View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/render_widget_host_unittest.cc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/render_widget_host_view_aura.h View 1 2 3 4 5 2 chunks +10 lines, -1 line 0 comments Download
M content/browser/renderer_host/render_widget_host_view_aura.cc View 1 2 3 4 5 6 7 9 3 chunks +10 lines, -3 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_aura_unittest.cc View 1 2 3 4 5 6 7 8 11 chunks +70 lines, -10 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_mac.h View 1 2 3 4 5 2 chunks +10 lines, -1 line 0 comments Download
M content/browser/renderer_host/render_widget_host_view_mac.mm View 1 2 3 4 5 6 7 9 4 chunks +12 lines, -4 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/render_widget_host_view_mac_unittest.mm View 1 2 3 4 5 6 7 9 chunks +55 lines, -9 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 2 3 4 5 6 7 9 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/web_contents/web_contents_view.h View 1 2 3 4 5 6 1 chunk +6 lines, -1 line 0 comments Download
M content/browser/web_contents/web_contents_view_android.h View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M content/browser/web_contents/web_contents_view_android.cc View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M content/browser/web_contents/web_contents_view_aura.h View 1 2 3 4 5 6 7 9 1 chunk +1 line, -1 line 0 comments Download
M content/browser/web_contents/web_contents_view_aura.cc View 1 2 3 4 5 6 7 9 3 chunks +3 lines, -3 lines 0 comments Download
M content/browser/web_contents/web_contents_view_guest.h View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M content/browser/web_contents/web_contents_view_guest.cc View 1 2 3 4 5 6 2 chunks +3 lines, -3 lines 0 comments Download
M content/browser/web_contents/web_contents_view_mac.h View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M content/browser/web_contents/web_contents_view_mac.mm View 1 2 3 4 5 6 10 3 chunks +3 lines, -3 lines 0 comments Download

Messages

Total messages: 25 (3 generated)
lazyboy
+sky for review. https://chromiumcodereview.appspot.com/647613002/diff/120001/content/browser/renderer_host/render_widget_host_view_mac.mm File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://chromiumcodereview.appspot.com/647613002/diff/120001/content/browser/renderer_host/render_widget_host_view_mac.mm#newcode575 content/browser/renderer_host/render_widget_host_view_mac.mm:575: render_widget_host_->SetView(NULL); It might be consistent to ...
6 years, 2 months ago (2014-10-10 01:22:58 UTC) #2
sky
How about a test in the content side?
6 years, 2 months ago (2014-10-10 02:18:46 UTC) #3
lazyboy
On 2014/10/10 02:18:46, sky wrote: > How about a test in the content side? OK, ...
6 years, 2 months ago (2014-10-10 02:29:04 UTC) #4
sky
Ideally unit test. How come you can't instantiate a *ViewGuest without chrome? Seems like you ...
6 years, 2 months ago (2014-10-10 17:22:55 UTC) #5
lazyboy
Hi, I've added content_unittest for aura and mac. These tests correctly fail without these change.
6 years, 2 months ago (2014-10-11 01:22:40 UTC) #6
sky
I don't feel that I have a good enough grasp on the ownership model to ...
6 years, 2 months ago (2014-10-13 17:04:13 UTC) #7
lazyboy
sky: I don't feel that I have a good enough grasp on the ownership model ...
6 years, 2 months ago (2014-10-13 21:54:01 UTC) #9
piman
On 2014/10/13 21:54:01, lazyboy wrote: > sky: > I don't feel that I have a ...
6 years, 2 months ago (2014-10-13 22:12:55 UTC) #10
piman
On Mon, Oct 13, 2014 at 3:12 PM, <piman@chromium.org> wrote: > On 2014/10/13 21:54:01, lazyboy ...
6 years, 2 months ago (2014-10-13 22:34:23 UTC) #11
lazyboy
> TBH this is adding workarounds for a hack that should never have been. RWH ...
6 years, 2 months ago (2014-10-14 22:02:14 UTC) #12
piman
https://chromiumcodereview.appspot.com/647613002/diff/530001/content/browser/renderer_host/render_widget_host_view_mac.mm File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://chromiumcodereview.appspot.com/647613002/diff/530001/content/browser/renderer_host/render_widget_host_view_mac.mm#newcode578 content/browser/renderer_host/render_widget_host_view_mac.mm:578: // typically a RenderWidgetHostViewChildFrame), then host_->GetView() won't nit: "typically ...
6 years, 2 months ago (2014-10-14 23:48:06 UTC) #13
lazyboy
Address comments in patchset #8 https://chromiumcodereview.appspot.com/647613002/diff/530001/content/browser/renderer_host/render_widget_host_view_mac.mm File content/browser/renderer_host/render_widget_host_view_mac.mm (right): https://chromiumcodereview.appspot.com/647613002/diff/530001/content/browser/renderer_host/render_widget_host_view_mac.mm#newcode578 content/browser/renderer_host/render_widget_host_view_mac.mm:578: // typically a RenderWidgetHostViewChildFrame), ...
6 years, 2 months ago (2014-10-15 04:50:11 UTC) #14
piman
lgtm
6 years, 2 months ago (2014-10-16 02:13:59 UTC) #15
lazyboy
https://chromiumcodereview.appspot.com/647613002/diff/610001/content/browser/web_contents/web_contents_view_mac.mm File content/browser/web_contents/web_contents_view_mac.mm (right): https://chromiumcodereview.appspot.com/647613002/diff/610001/content/browser/web_contents/web_contents_view_mac.mm#newcode301 content/browser/web_contents/web_contents_view_mac.mm:301: if (!is_guest_view_hack && delegate()) { I needed to add ...
6 years, 2 months ago (2014-10-16 06:14:24 UTC) #16
piman
https://chromiumcodereview.appspot.com/647613002/diff/610001/content/browser/web_contents/web_contents_view_mac.mm File content/browser/web_contents/web_contents_view_mac.mm (right): https://chromiumcodereview.appspot.com/647613002/diff/610001/content/browser/web_contents/web_contents_view_mac.mm#newcode301 content/browser/web_contents/web_contents_view_mac.mm:301: if (!is_guest_view_hack && delegate()) { On 2014/10/16 06:14:24, lazyboy ...
6 years, 2 months ago (2014-10-16 20:47:48 UTC) #17
lazyboy
Patchset #11 https://chromiumcodereview.appspot.com/647613002/diff/610001/content/browser/web_contents/web_contents_view_mac.mm File content/browser/web_contents/web_contents_view_mac.mm (right): https://chromiumcodereview.appspot.com/647613002/diff/610001/content/browser/web_contents/web_contents_view_mac.mm#newcode301 content/browser/web_contents/web_contents_view_mac.mm:301: if (!is_guest_view_hack && delegate()) { On 2014/10/16 ...
6 years, 2 months ago (2014-10-17 00:46:00 UTC) #18
piman
LGTM, thanks!
6 years, 2 months ago (2014-10-17 03:37:58 UTC) #19
lazyboy
Scott, can I get LGTM for: chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm Thanks.
6 years, 2 months ago (2014-10-17 05:39:12 UTC) #20
sky
LGTM
6 years, 2 months ago (2014-10-20 15:48:01 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/647613002/630001
6 years, 2 months ago (2014-10-20 16:52:42 UTC) #23
commit-bot: I haz the power
Committed patchset #11 (id:630001)
6 years, 2 months ago (2014-10-20 17:16:22 UTC) #24
commit-bot: I haz the power
6 years, 2 months ago (2014-10-20 17:17:20 UTC) #25
Message was sent while issue was closed.
Patchset 11 (id:??) landed as
https://crrev.com/549b3b4f0cf5691d093823f285ffd437614af1f6
Cr-Commit-Position: refs/heads/master@{#300286}

Powered by Google App Engine
This is Rietveld 408576698