Closed Bug 1407069 Opened 7 years ago Closed 7 years ago

Playing A YouTube Video With WebRender Enabled And Leaving It Alone Causes Shared Memory To Continuously Rise

Categories

(Core :: Graphics: WebRender, defect, P1)

58 Branch
x86_64
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox57 --- unaffected
firefox58 --- unaffected

People

(Reporter: kah0922, Assigned: nical)

References

Details

(Whiteboard: [wr-mvp])

Attachments

(2 files, 3 obsolete files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0 Build ID: 20171009100134 Steps to reproduce: This is on openSUSE Tumbleweed with a Radeon RX460. Enable WebRender and GPU Process. Play a YouTube video. Disable subtitles (and possibly annotations as well) While the video is playing, do not interact with the video window in any way. Actual results: Shared Memory usage of the Web Process and the GPU process will climb continuously until the computer runs out of memory. Strangely, the Shared Memory resets itself to normal if you interact with the YouTube video by either hovering over it with your mouse or enabling subtitles. Expected results: Shared Memory should not reach 4GBs and crash the web browser.
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
Whiteboard: [wr-mvp] [triage]
I take a look.
Assignee: nobody → sotaro.ikeda.g
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P1
Whiteboard: [wr-mvp] [triage] → [wr-mvp]
It is a fallout from pre AsyncImagePipelineManager era. On current gecko, each video pipe line has each pipeline id and epoch. We need to use them. But WebRenderImageHost::UseTextureHost() still use WebRenderBridgeParent's pipeline id and epoch. https://dxr.mozilla.org/mozilla-central/source/gfx/layers/wr/WebRenderImageHost.cpp#197
(In reply to Sotaro Ikeda [:sotaro] from comment #2) > It is a fallout from pre AsyncImagePipelineManager era. On current gecko, > each video pipe line has each pipeline id and epoch. We need to use them. > But WebRenderImageHost::UseTextureHost() still use WebRenderBridgeParent's > pipeline id and epoch. > > https://dxr.mozilla.org/mozilla-central/source/gfx/layers/wr/ > WebRenderImageHost.cpp#197 It is a fallout, but it accidentally minimize the memory leak. Actual source of memory leak is injected by Bug 1383786. It minimize updating DisplayList. The updating DisplayList updates also epoch. AsyncImagePipelineManager uses the epoch to recognize end of usage of WebRenderTextureHost by WebRender.
Blocks: 1383786
(In reply to Sotaro Ikeda [:sotaro] from comment #3) > > Actual source of memory leak is injected by Bug 1383786. It minimize > updating DisplayList. The updating DisplayList updates also epoch. > AsyncImagePipelineManager uses the epoch to recognize end of usage of > WebRenderTextureHost by WebRender. If there is a update of WebRenderTextureHost usage in resourceUpdates, we need to push DisplayList with current gecko and WebRender.
Bug 1383786 also removed a case that ImageHost does not have TextureHost for composite. We also need to handle this case.
Attachment #8917657 - Attachment description: patch - Make ApplyAsyncImages() as to push display list if WebRenderTextureHosts usages are updated → patch part 1 - Make ApplyAsyncImages() as to push display list if WebRenderTextureHosts usages are updated
Attachment #8917658 - Attachment description: patch - Do not hold external image in WebRenderImageHost::SetCurrentTextureHost() if ImageHost is async → patch part 2 - Do not hold external image in WebRenderImageHost::SetCurrentTextureHost() if ImageHost is async
R4 failed because of TEST-UNEXPECTED-PASS. REFTEST TEST-UNEXPECTED-PASS | file:///builds/worker/workspace/build/tests/reftest/tests/layout/reftests/bugs/579323-1.html == file:///builds/worker/workspace/build/tests/reftest/tests/layout/reftests/bugs/579323-1-ref.html | image comparison, max difference: 0,
(In reply to Sotaro Ikeda [:sotaro] from comment #9) > R4 failed because of TEST-UNEXPECTED-PASS. > > REFTEST TEST-UNEXPECTED-PASS | > file:///builds/worker/workspace/build/tests/reftest/tests/layout/reftests/ > bugs/579323-1.html == > file:///builds/worker/workspace/build/tests/reftest/tests/layout/reftests/ > bugs/579323-1-ref.html | image comparison, max difference: 0, The test was set failed by Bug 1403457 because of regression of bug 1383786.
Attachment #8917657 - Flags: review?(nical.bugzilla)
Attachment #8917658 - Flags: review?(nical.bugzilla)
Attachment #8917738 - Flags: review?(nical.bugzilla)
Comment on attachment 8917657 [details] [diff] [review] patch part 1 - Make ApplyAsyncImages() as to push display list if WebRenderTextureHosts usages are updated Review of attachment 8917657 [details] [diff] [review]: ----------------------------------------------------------------- Sorry, this looks like a step in the wrong direction. If there is a bug in the way we manage the lifetime of external images, let's figure it out and fix it, but it is important to not rebuild scenes when we don't need to, especially during video playback.
I created the patch to fix the problem soon. We could address the lifetime of external images in a different bug.
I understand. I don't think we need to hurry about fixing this to the point of undoing something that we want. Let's use this bug to look for a long term solution (but we should definitely fix this soon-ish even if it takes a week or two).
(In reply to Keith Hizal from comment #0) > Linux x86_64; rv:58.0 > This is on openSUSE Tumbleweed with a Radeon RX460. > Enable WebRender and GPU Process. I have Nightly 58 x64 @ Debian Testing (KDE, Radeon RX480(!), same prefs) and saw similar, but not a problem with "shared memory", rather "memory"(attachment 8914537 [details]): I think(!) blob-images was the cause: bug 1405168. Since I disabled it I haven't had such a memory problem so far. I may be totally wrong and don't know what I'm talking about. (Unrelated: bug 1402067)
I filed https://github.com/servo/webrender/issues/1870 to address the missing webrender bits.
I created Bug 1408348 just to address lifetime handling of WebRenderTextureHost, I am not sure yet https://github.com/servo/webrender/issues/1870 could help well to the lifetime handling.
Attachment #8917657 - Flags: review?(nical.bugzilla)
Attachment #8917658 - Flags: review?(nical.bugzilla)
Attachment #8917738 - Flags: review?(nical.bugzilla)
Depends on: 1408348
(In reply to Jan Andre Ikenmeyer [:darkspirit] from comment #16) > I have Nightly 58 x64 @ Debian Testing (KDE, Radeon RX480(!), same prefs) > and saw similar, but not a problem with "shared memory", rather > "memory"(attachment 8914537 [details]): I think(!) blob-images was the > cause: bug 1405168. Since I disabled it I haven't had such a memory problem > so far. I may be totally wrong and don't know what I'm talking about. > (Unrelated: bug 1402067) I disabled blob images and still encountered the same problem as before.
UpdatePipelineResources was temporarily added to webrender's API to address this use case (bumping the epoch when resources are updated with no new display list). In the longer run we'll refactor webrender's API to more flexibly compose transactions and the new UpdatePipelineResources message will be removed, but in the mean time we can address this bug.
Attachment #8920101 - Flags: review?(sotaro.ikeda.g)
> I created Bug 1408348 just to address lifetime handling of WebRenderTextureHost, I am not sure yet https://github.com/servo/webrender/issues/1870 could help well to the lifetime handling. Oops I missed that, the patch I just posted may not be up to date with your latest work, I'll have a look.
Updated patch. I had forgotten to call HoldExternalImage when not going through the set_display_list path. With this patch I have been able to confirm that all epochs are correctly reported back when updating images using the UpdatePipelineResources api. However, the number of live TextureHosts is still growing to worryingly high levels (~600 just watching a video). It appears that the vast majority most of the deallocations are happening when the TextureParent is destroyed, which would indicate that a lot of the textures are held alive on the content side. Looks like there is more to this issue than the compositor-side lifetime management.
Attachment #8920101 - Attachment is obsolete: true
Attachment #8920101 - Flags: review?(sotaro.ikeda.g)
Attachment #8920125 - Flags: review?(sotaro.ikeda.g)
Comment on attachment 8920125 [details] [diff] [review] Associate epochs to frames with image updates Review of attachment 8920125 [details] [diff] [review]: ----------------------------------------------------------------- ::: gfx/layers/wr/AsyncImagePipelineManager.cpp @@ +272,5 @@ > // We don't need to update the display list, either because we can't or because > // the previous one is still up to date. > // We may, however, have updated some resources. > + mApi->UpdatePipelineResources(resourceUpdates, pipelineId, epoch); > + if (mCurrentTexture) { Sorry there's a mistake here (should be pipeline->mCurrentTexture), it's fixed locally.
Attachment #8917657 - Attachment is obsolete: true
Attachment #8917658 - Attachment is obsolete: true
Attachment #8917738 - Attachment is obsolete: true
Attachment #8917658 - Attachment is obsolete: false
(In reply to Nicolas Silva [:nical] from comment #22) > Created attachment 8920125 [details] [diff] [review] > Associate epochs to frames with image updates > > Updated patch. I had forgotten to call HoldExternalImage when not going > through the set_display_list path. > > With this patch I have been able to confirm that all epochs are correctly > reported back when updating images using the UpdatePipelineResources api. > However, the number of live TextureHosts is still growing to worryingly high > levels (~600 just watching a video). It appears that the vast majority most > of the deallocations are happening when the TextureParent is destroyed, > which would indicate that a lot of the textures are held alive on the > content side. :nical, Isn't the problem be fixed with attachment 8917658 [details] [diff] [review]?
Comment on attachment 8920125 [details] [diff] [review] Associate epochs to frames with image updates Review of attachment 8920125 [details] [diff] [review]: ----------------------------------------------------------------- Looks good. Thanks!
Attachment #8920125 - Flags: review?(sotaro.ikeda.g) → review+
Assigned to nical, since he created the patch.
Assignee: sotaro.ikeda.g → nical.bugzilla
> :nical, Isn't the problem be fixed with attachment 8917658 [details] [diff] [review] [diff] [review]? Marvelous! it does fix the problem indeed \o/
Attachment #8917658 - Flags: review+
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/73adbbe06358 Associate epochs to async image updates. r=sotaro https://hg.mozilla.org/integration/mozilla-inbound/rev/647efba379ee Do not hold external image in SetCurrentTextureHost if ImageHost is async. r=nical
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
See Also: → 1421337
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: