RESOLVED FIXED 101656
Coordinated Graphics: Remove a backing store of GraphicsLayer when the layer is far from the viewport.
https://bugs.webkit.org/show_bug.cgi?id=101656
Summary Coordinated Graphics: Remove a backing store of GraphicsLayer when the layer ...
Dongseong Hwang
Reported 2012-11-08 15:25:31 PST
TiledBackingStore computes cover and keep rects to create, keep or remove tiles smartly, but currently TiledBackingStore expects a contents rect is big enough to cover the visibleRect. However, when CoordinatedGraphicsLayer uses TBS, it is usually wrong expectation. We must compute cover and keep rects using the visibleRect, not intersected visibleRect with contentsRect, because TBS can be used as a backing store of GraphicsLayer.
Attachments
Patch (5.45 KB, patch)
2012-11-08 15:32 PST, Dongseong Hwang
no flags
Patch (8.33 KB, patch)
2012-11-09 02:26 PST, Dongseong Hwang
no flags
Patch (8.38 KB, patch)
2012-11-09 03:07 PST, Dongseong Hwang
no flags
Patch (7.94 KB, patch)
2012-11-09 03:16 PST, Dongseong Hwang
no flags
Patch (7.58 KB, patch)
2012-11-09 03:32 PST, Dongseong Hwang
no flags
Dongseong Hwang
Comment 1 2012-11-08 15:32:54 PST
Dongseong Hwang
Comment 2 2012-11-08 15:35:43 PST
Comment on attachment 173135 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=173135&action=review > Source/WebCore/ChangeLog:31 > + This representation is fine on terminal using a monospace font
Kenneth Rohde Christiansen
Comment 3 2012-11-09 02:24:56 PST
Comment on attachment 173135 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=173135&action=review Cool you found this! > Source/WebCore/ChangeLog:40 > + Changing cache policy is not testable in layout tests. Could we find another way of testing it? unit tests? > Source/WebCore/platform/graphics/TiledBackingStore.cpp:278 > + * We must create or keep the tiles on the HERE region. s/on/in/ > Source/WebCore/platform/graphics/TiledBackingStore.cpp:312 > - double distance = tileDistance(visibleRect, currentCoordinate); > + double distance = tileDistance(intersectedVisibleRect, currentCoordinate); why not just use m_visibleRect here? ie. why create the separate intersectedVisibleRect ? Where is it intersected? > Source/WebCore/platform/graphics/TiledBackingStore.cpp:345 > + // If candidateSize is bigger than bounds (i.e. TBS is used as a backing store of GraphicsLayer), we skip the below adjusting logic which expects bounds covers the given rect. bounds TO cover the ...
Dongseong Hwang
Comment 4 2012-11-09 02:26:58 PST
Kenneth Rohde Christiansen
Comment 5 2012-11-09 02:33:51 PST
Comment on attachment 173248 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=173248&action=review > Source/WebCore/platform/graphics/TiledBackingStore.h:107 > - IntRect visibleContentsRect() const; > + IntRect visibleContentsRectOnBacking() const; > + IntRect visibleRectOnBacking() const; > IntRect visibleRect() const; This is becoming too confusing, between what they represents and in what coordinate system.
Dongseong Hwang
Comment 6 2012-11-09 02:42:12 PST
Comment on attachment 173248 [details] Patch I've tested various sites and checked tiles are removed properly. After this patch, Coordinated Graphics uses pretty less memory. I explain in detail below. View in context: https://bugs.webkit.org/attachment.cgi?id=173248&action=review > Source/WebCore/platform/graphics/TiledBackingStore.cpp:244 > + return coverageRatio(visibleContentsRectOnBacking()) == 1.0f; The logic is not changed because visibleContentsRectOnBacking is renamed from visibleContentsRect. > Source/WebCore/platform/graphics/TiledBackingStore.cpp:284 > m_visibleRect = visibleRect; m_visibleRect keeps visibleRect(), not visibleRectOnBacking(), because we must remove invisible tiles. void TiledBackingStore::coverWithTilesIfNeeded(const FloatPoint& trajectoryVector) { IntRect visibleRect = this->visibleRect(); ... if (m_trajectoryVector == normalizedVector && m_visibleRect == visibleRect) return; ... m_visibleRect = visibleRect; createTiles(); } visibleRectOnBacking() returns IntRect() when we scroll the given TBS of GraphicsLayer off the viewport, and then coverWithTilesIfNeeded() early returns. It means we can have the change to remove tiles. So we must keep visibleRect(). > Source/WebCore/platform/graphics/TiledBackingStore.cpp:295 > + return; If we don't return here, createTile() creates one tile because tileCoordinateForPoint(IntRect()) == Tile::Coordinate(0, 0). It means we execute following "for loop statement" one time. Tile::Coordinate topLeft = tileCoordinateForPoint(coverRect.location()); for (int yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { So we must early return to save memory.
Dongseong Hwang
Comment 7 2012-11-09 02:54:01 PST
(In reply to comment #3) > (From update of attachment 173135 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=173135&action=review > > Cool you found this! > > Could we find another way of testing it? unit tests? I think unit test is possible. After adding API to query the count of tile, we can check the count of tiles during scrolling. > > s/on/in/ > > why not just use m_visibleRect here? ie. why create the separate intersectedVisibleRect ? Where is it intersected? The names are changed in the second patch and I explained. > > bounds TO cover the ... Thanks for review! We posted simultaneously. I'll update :) (In reply to comment #5) > (From update of attachment 173248 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=173248&action=review > > > Source/WebCore/platform/graphics/TiledBackingStore.h:107 > > - IntRect visibleContentsRect() const; > > + IntRect visibleContentsRectOnBacking() const; > > + IntRect visibleRectOnBacking() const; > > IntRect visibleRect() const; > > This is becoming too confusing, between what they represents and in what coordinate system. I agree. If name contains "Contents", it is on the contents coordinate system. I want to express which to be intersected with m_rect or not. Could you suggest?
Dongseong Hwang
Comment 8 2012-11-09 03:07:17 PST
Kenneth Rohde Christiansen
Comment 9 2012-11-09 03:12:09 PST
Comment on attachment 173252 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=173252&action=review > Source/WebCore/platform/graphics/TiledBackingStore.cpp:283 > const IntRect visibleRect = this->visibleRect(); mapFromContents(m_client->tiledBackingStoreVisibleRect()); and get rid of visibleRect?
Kenneth Rohde Christiansen
Comment 10 2012-11-09 03:12:12 PST
Comment on attachment 173252 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=173252&action=review > Source/WebCore/platform/graphics/TiledBackingStore.cpp:283 > const IntRect visibleRect = this->visibleRect(); mapFromContents(m_client->tiledBackingStoreVisibleRect()); and get rid of visibleRect?
Dongseong Hwang
Comment 11 2012-11-09 03:16:13 PST
Dongseong Hwang
Comment 12 2012-11-09 03:18:06 PST
Comment on attachment 173254 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=173254&action=review > Source/WebCore/platform/graphics/TiledBackingStore.h:107 > IntRect visibleRect() const; How about these names? Is it confused yet? (In reply to comment #3) > (From update of attachment 173135 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=173135&action=review > > Source/WebCore/platform/graphics/TiledBackingStore.cpp:312 > > - double distance = tileDistance(visibleRect, currentCoordinate); > > + double distance = tileDistance(intersectedVisibleRect, currentCoordinate); > > why not just use m_visibleRect here? ie. why create the separate intersectedVisibleRect ? Where is it intersected? you are right! intersectedVisibleRect is more reasonable. now intersectedVisibleRect is boundedVisibleRect.
Dongseong Hwang
Comment 13 2012-11-09 03:18:58 PST
(In reply to comment #10) > (From update of attachment 173252 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=173252&action=review > > > Source/WebCore/platform/graphics/TiledBackingStore.cpp:283 > > const IntRect visibleRect = this->visibleRect(); > > mapFromContents(m_client->tiledBackingStoreVisibleRect()); > and get rid of visibleRect? Ok, I'll get rid of it!
Kenneth Rohde Christiansen
Comment 14 2012-11-09 03:19:29 PST
yeah fine!
Dongseong Hwang
Comment 15 2012-11-09 03:32:15 PST
Dongseong Hwang
Comment 16 2012-11-09 03:33:14 PST
Comment on attachment 173258 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=173258&action=review > Source/WebCore/platform/graphics/TiledBackingStore.h:105 > IntRect visibleRect() const; I removed boundedSomthings instead of visibleRect.
WebKit Review Bot
Comment 17 2012-11-09 04:13:54 PST
Comment on attachment 173258 [details] Patch Clearing flags on attachment: 173258 Committed r134048: <http://trac.webkit.org/changeset/134048>
WebKit Review Bot
Comment 18 2012-11-09 04:13:59 PST
All reviewed patches have been landed. Closing bug.
Dongseong Hwang
Comment 19 2012-11-09 16:04:17 PST
(In reply to comment #18) > All reviewed patches have been landed. Closing bug. Thank you for review!
Note You need to log in before you can comment on or make changes to this bug.