Bug 83316

Summary: [chromium] Remove viewport memory restrictions
Product: WebKit Reporter: Dana Jansens <danakj>
Component: New BugsAssignee: Dana Jansens <danakj>
Status: RESOLVED FIXED    
Severity: Normal CC: backer, cc-bugs, enne, epenner, jamesr, nduca, piman, vangelis, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 83899    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Dana Jansens 2012-04-05 14:50:15 PDT
[chromium] Remove viewport memory restrictions and remove duplicate memory limit reductions on setVisible(false)
Comment 1 Dana Jansens 2012-04-05 14:50:50 PDT
Created attachment 135909 [details]
Patch
Comment 2 WebKit Review Bot 2012-04-05 14:57:40 PDT
Attachment 135909 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Dana Jansens 2012-04-05 18:12:44 PDT
Created attachment 135955 [details]
Patch
Comment 4 Dana Jansens 2012-04-05 18:13:42 PDT
Proper changelog with explanation :)
Comment 5 Nat Duca 2012-04-05 23:27:43 PDT
Can you explain the rationale on some of this? I've gotten a little stale on this material lately...
Comment 6 Nat Duca 2012-04-05 23:28:26 PDT
Oh look. Nice long changelog on the second patch. Whommmp!
Comment 7 Nat Duca 2012-04-05 23:33:19 PDT
Comment on attachment 135955 [details]
Patch

So two questions:
1) does this regress android in any way? Ping epenner to see if the loss of a viewport multiplier makes sense to him
2) should we be mucking around with this code at all? In particular, I'm wondering if we should focus on adding memory request APIs to the GpuMemoryManager and then having those limits drive the texture manager limits.
Comment 8 Dana Jansens 2012-04-06 08:08:36 PDT
(In reply to comment #7)
> (From update of attachment 135955 [details])
> So two questions:
> 1) does this regress android in any way? Ping epenner to see if the loss of a viewport multiplier makes sense to him

Will discuss.

> 2) should we be mucking around with this code at all? In particular, I'm wondering if we should focus on adding memory request APIs to the GpuMemoryManager and then having those limits drive the texture manager limits.

I think this is potentially backportable to M19, where we are seeing problems already, especially since Accelerated Canvas is turning on the compositor more often. I agree GpuMemoryManager is the way to go to make this better.
Comment 9 Eric Penner 2012-04-06 10:22:16 PDT
Yeah we need the viewport multiplier to keep the limit lower on low resolution devices. The original patch had logic to prevent the some of the problems described (issues with small viewports), but it was removed before landing.

If a short term fix is needed why not just increase the viewport size or multiplier?
Comment 10 Vangelis Kokkevis 2012-04-06 10:50:00 PDT
(In reply to comment #9)
> Yeah we need the viewport multiplier to keep the limit lower on low resolution devices. The original patch had logic to prevent the some of the problems described (issues with small viewports), but it was removed before landing.
> 
> If a short term fix is needed why not just increase the viewport size or multiplier?

The problem is that the viewport size isn't necessarily a good indicator of how much vram is available, at least not for desktop platforms. Maybe a more flexible solution would be to set the min and max values once, at TextureManager creation time and let each platform decide what it wants to set them to.  For example on Android we can use the viewport size (which will most likely be constant) and on the desktop use some other reasonable fixed value.
Comment 11 Nat Duca 2012-04-06 11:03:34 PDT
Is there a crbug that justifies M19-related flailing?
Comment 12 Dana Jansens 2012-04-06 11:07:52 PDT
(In reply to comment #11)
> Is there a crbug that justifies M19-related flailing?

http://code.google.com/p/chromium/issues/detail?id=121605 : There're are a few problems caused there due to OOM. But no OOM would avoid them. 

http://code.google.com/p/chromium/issues/detail?id=121557 : Also causes OOM.
Comment 13 Dana Jansens 2012-04-06 11:15:16 PDT
Created attachment 136044 [details]
Patch

This keeps the multipliers for android as requested by Eric. I updated the android multipliers/values to what they are actually using downstream.
Comment 14 Eric Penner 2012-04-06 11:37:30 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > Yeah we need the viewport multiplier to keep the limit lower on low resolution devices. The original patch had logic to prevent the some of the problems described (issues with small viewports), but it was removed before landing.
> > 
> > If a short term fix is needed why not just increase the viewport size or multiplier?
> 
> The problem is that the viewport size isn't necessarily a good indicator of how much vram is available, at least not for desktop platforms. Maybe a more flexible solution would be to set the min and max values once, at TextureManager creation time and let each platform decide what it wants to set them to.  For example on Android we can use the viewport size (which will most likely be constant) and on the desktop use some other reasonable fixed value.

Yeah makes sense. The point is to prevent hitting a real OOM (vram limit). We do set the max limit at one other place (to prevent pre-painting from consuming the entire max limit), so I like Dana's new patch which just ignores the viewport on Desktop.
Comment 15 Nat Duca 2012-04-10 13:03:58 PDT
Comment on attachment 136044 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=136044&action=review

I would prefer if the refactoring "foremost, make no change" was separate from behavior changing.

> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp:176
> +    if (m_contentsTextureManager && m_layerRendererInitialized)

why?
Comment 16 Adrienne Walker 2012-04-10 20:52:38 PDT
Comment on attachment 136044 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=136044&action=review

> Source/WebCore/ChangeLog:3
> +        [chromium] Remove viewport memory restrictions and remove duplicate memory limit reductions on setVisible(false)

I think you should separate these two changes, especially if you want to merge one of them.
Comment 17 Dana Jansens 2012-04-12 18:22:41 PDT
Created attachment 137014 [details]
Patch
Comment 18 Dana Jansens 2012-04-12 21:08:46 PDT
I've split this patch up. This CL removes the viewport restriction on the preferred/max memory limits. And removes the min memory limit entirely.

This means instead of possibly preserving some number of prepainted tiles, we evict all non-visible tiles when we background a tab (if we aren't deleting all textures anyways).
Comment 19 Vangelis Kokkevis 2012-04-13 09:31:25 PDT
Comment on attachment 137014 [details]
Patch

Why not set these limits via API calls to the TextureManager rather than baking them into the class? We'll need that functionality soon anyway, when gpu memory manager starts telling the renderers how much memory they can use.
Comment 20 Dana Jansens 2012-04-13 09:45:23 PDT
(In reply to comment #19)
> (From update of attachment 137014 [details])
> Why not set these limits via API calls to the TextureManager rather than baking them into the class? We'll need that functionality soon anyway, when gpu memory manager starts telling the renderers how much memory they can use.

I am not sure I get what you mean. What sort of API calls are you thinking? They are currently baked into the TextureManager, but we'd like to get them from GpuMemManager. I think we'll likely deal with the GpuMemManager in a separate PriorityTextureManager implementation, and we can probably just leave this one as fixed values anyhow as it'll be replaced by the new one.

For this patch, though, I'm approaching it as a minimal thing to make us not use the viewport, so that we can easily merge it back to M19.
Comment 21 Vangelis Kokkevis 2012-04-13 10:34:54 PDT
(In reply to comment #20)
> (In reply to comment #19)
> > (From update of attachment 137014 [details] [details])
> > Why not set these limits via API calls to the TextureManager rather than baking them into the class? We'll need that functionality soon anyway, when gpu memory manager starts telling the renderers how much memory they can use.
> 
> I am not sure I get what you mean. What sort of API calls are you thinking? They are currently baked into the TextureManager, but we'd like to get them from GpuMemManager. I think we'll likely deal with the GpuMemManager in a separate PriorityTextureManager implementation, and we can probably just leave this one as fixed values anyhow as it'll be replaced by the new one.
> 
> For this patch, though, I'm approaching it as a minimal thing to make us not use the viewport, so that we can easily merge it back to M19.

What I had in mind was defining a method like:

TextureManager::SetLimits(min, max, viewportMultiplier)

so that we can set different limits depending on what the TextureManager is used for (e.g. is this the layer or the rendersurface TM) and we can also reset them as needed.

However, if we are going to throw away the TM class once we implement the GpuMemManager then maybe it's not worth it.
Comment 22 Dana Jansens 2012-04-13 10:45:54 PDT
(In reply to comment #21)
> What I had in mind was defining a method like:
> 
> TextureManager::SetLimits(min, max, viewportMultiplier)
> 
> so that we can set different limits depending on what the TextureManager is used for (e.g. is this the layer or the rendersurface TM) and we can also reset them as needed.

Oh ok. So basically dropping the static methods and setMax/setPreferred from the class and just calling the setLimits() instead.

> However, if we are going to throw away the TM class once we implement the GpuMemManager then maybe it's not worth it.

I think it's something we could do separately from this CL either way. I think that would be a nicer API for the current TM as well to even just say setLimits(viewportSize), but maybe not worth it as you say.
Comment 23 Adrienne Walker 2012-04-13 12:49:11 PDT
Comment on attachment 137014 [details]
Patch

R=me.  Thanks for chopping this up somewhat.
Comment 24 WebKit Review Bot 2012-04-13 17:42:16 PDT
Comment on attachment 137014 [details]
Patch

Clearing flags on attachment: 137014

Committed r114191: <http://trac.webkit.org/changeset/114191>
Comment 25 WebKit Review Bot 2012-04-13 17:42:22 PDT
All reviewed patches have been landed.  Closing bug.