Skip to content

Commit

Permalink
app_server: plug leak of layers when empty clipping
Browse files Browse the repository at this point in the history
* If there is an empty clipping region (invalid clipping) for the
  current view, a new layer could still be started, but not ended
  anymore. That's because unlike begin layer, end layer is handled in
  _DispatchViewDrawingMessage (because it can do actual drawing)
  and this method checks whether the clipping is valid and bails out
  if it isn't.

* Add an exception for the AS_VIEW_END_LAYER command code to still
  process it even when the clipping is invalid. The layer itself
  can after all set a valid clipping later on when its command list
  is played back. And even if it doesn't, we still have to play it
  to make sure nested layers are cleaned up.

* Fixes the memory leak in #12460 where webkit creates
  said situation: it had a layer open and then the closing was
  ignored due to empty clipping. All subsequent layer calls created
  nested layers in that one, hundreds of them, and their BPictures
  contained bitmaps, quickly eating up and leaking hundreds of MiB
  in app_server.
  • Loading branch information
juafromspace committed Nov 14, 2015
1 parent 0fab27a commit 10df154
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/servers/app/ServerWindow.cpp
Expand Up @@ -2335,7 +2335,13 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code,
}

_UpdateCurrentDrawingRegion();
if (fCurrentDrawingRegion.CountRects() <= 0) {
if (fCurrentDrawingRegion.CountRects() <= 0 && code != AS_VIEW_END_LAYER) {
// If the command is AS_VIEW_END_LAYER, then we continue even if
// the clipping region is empty. The layer itself might set a valid
// clipping while its contents are drawn, and even if it doesn't,
// we must still play back its picture so that we don't leak
// nested layer instances.

DTRACE(("ServerWindow %s: _DispatchViewDrawingMessage(): View: %s, "
"INVALID CLIPPING!\n", Title(), fCurrentView->Name()));
if (link.NeedsReply()) {
Expand Down

0 comments on commit 10df154

Please sign in to comment.