New issue
Advanced search Search tips

Issue 857547 link

Starred by 2 users

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug
Proj-VR



Sign in to add a comment

GPU process memory leak when re-entering WebXR

Project Member Reported by klausw@chromium.org, Jun 28 2018

Issue description

Chrome Version: ToT
OS: Android

What steps will reproduce the problem?
(1) Open a WebXR page such as https://immersive-web.github.io/webxr-samples/tests/cube-sea.html
(2) repeatedly enter and exit VR presentation
(3) run "adb shell ps" | grep privileged

What is the expected result?
Roughly constant memory use

What happens instead?
GPU process memory grows steadily

SharedBuffer mode - grows from 1.27G to 1.94G:

ps1:u0_a168      20145   737 1269316  59672 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps2:u0_a168      20145   737 1340708  61124 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps3:u0_a168      20145   737 1427744  62732 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps4:u0_a168      20145   737 1579496  64276 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps5:u0_a168      20145   737 1636764  66084 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps6:u0_a168      20145   737 1768036  66784 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps7:u0_a168      20145   737 1825232  68616 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps8:u0_a168      20145   737 1937436  69836 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0


GpuFence mode - grows from 1.38G to 2.76G:

ps1:u0_a172       5347   737 1384840  61380 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps2:u0_a172       5347   737 1576388  62980 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps3:u0_a172       5347   737 1758224  65320 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps4:u0_a172       5347   737 1969968  67204 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps5:u0_a172       5347   737 2200028  69644 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps6:u0_a172       5347   737 2375100  70544 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps7:u0_a172       5347   737 2568256  69804 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0
ps8:u0_a172       5347   737 2760020  62268 SyS_epoll_wait f1995a70 S org.chromium.chrome:privileged_process0

Since the memory growth seems to be higher for the "GpuFence" path, I'm suspecting it may be related to the transfer Surface. That still gets allocated in SharedBuffer mode but isn't used for transfer.

I ran into this while debugging VrShellTransitionTest#testWebXrReEntryFromVrBrowser for  issue 855722  when adding an 8-iteration loop around reEntryFromVrBrowserImpl. It also reproduces manually.
 

Comment 1 by klausw@chromium.org, Jun 29 2018

Still investigating, but there seem to be multiple problems.

### GPU process memory increases when exiting presentation. 

Issue seems to be a reference loop with XRWebGLDrawingBuffer and its ColorBuffer objects keeping each other alive. A comment in xr_webgl_drawing_buffer.h mentions "DrawingBuffer is explicitly destroyed by the beginDestruction method", but this method wasn't copied over from the original drawing_buffer code. Adding a cleanup function appears to fix this:

void XRWebGLDrawingBuffer::DestroyBuffers() {
  back_color_buffer_ = nullptr;
  front_color_buffer_ = nullptr;
  recycled_color_buffer_queue_.clear();
}

### SharedBuffer mode allocates a Surface but doesn't use it

I have a WIP patch that skips creating the SurfaceTexture/Surface pair in VrShellGl in SharedBuffer mode. With that and the previous patch, memory consumption seems stable.

### Unconfirmed: incomplete Surface cleanup in VrShellGl?

Still investigating, but it appears that VrShellGl may not be fully releasing resources on destruction. I tried adding webvr_surface_texture_->ReleaseBackBuffers() in the destructor, but I'm not sure if there's still an issue with Surface refcounting.

Project Member

Comment 2 by bugdroid1@chromium.org, Jun 29 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9bc221409571d695d0ee31557351841a7d8a5462

commit 9bc221409571d695d0ee31557351841a7d8a5462
Author: Klaus Weidner <klausw@chromium.org>
Date: Fri Jun 29 18:00:10 2018

Don't create a Surface for WebXR SharedBuffer mode

Managing the Surface/SurfaceTexture pair is somewhat expensive,
and we don't need it for SharedBuffer transport. Now that the
mailbox_to_surface_bridge supports surfaceless initialization
(thanks to AR mode), use that to avoid this allocation.

This required some minor reshuffling to ensure we have the
right initialization order.

BUG=857547

Change-Id: I7edca6e791f9b13bef4a3a50266715182517fdef
Reviewed-on: https://chromium-review.googlesource.com/1120677
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571541}
[modify] https://crrev.com/9bc221409571d695d0ee31557351841a7d8a5462/chrome/browser/android/vr/vr_shell_gl.cc
[modify] https://crrev.com/9bc221409571d695d0ee31557351841a7d8a5462/chrome/browser/android/vr/vr_shell_gl.h

Project Member

Comment 3 by bugdroid1@chromium.org, Jun 29 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9fe2370a5c269474a041a316011b41deae036acc

commit 9fe2370a5c269474a041a316011b41deae036acc
Author: Klaus Weidner <klausw@chromium.org>
Date: Fri Jun 29 22:55:08 2018

Avoid WebXR resource leak on destruction

The DrawingBuffer code that WebXRDrawingBuffer is based on requires
a BeginDestruction method to be called to break a reference loop.
Both DrawingBuffer and its ColorBuffer subclass are refcounted and
store references to each other.

Add the BeginDestruction method to WebXRDrawingBuffer which was mentioned
in a copied comment but not implemented.

BUG=857547

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I3bef8e975c26ca432eafe7eb4ba8c4daae715796
Reviewed-on: https://chromium-review.googlesource.com/1120645
Reviewed-by: Ian Vollick <vollick@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571693}
[modify] https://crrev.com/9fe2370a5c269474a041a316011b41deae036acc/third_party/blink/renderer/modules/xr/xr_webgl_layer.cc
[modify] https://crrev.com/9fe2370a5c269474a041a316011b41deae036acc/third_party/blink/renderer/platform/graphics/gpu/xr_webgl_drawing_buffer.cc
[modify] https://crrev.com/9fe2370a5c269474a041a316011b41deae036acc/third_party/blink/renderer/platform/graphics/gpu/xr_webgl_drawing_buffer.h

Labels: -VR-Caught-By-Test XR-Caught-By-Test

Sign in to add a comment