Skip to content

Commit

Permalink
Call layer.setNeedsDisplay on show. (#17096)
Browse files Browse the repository at this point in the history
The `AvaloniaNative.GlPlatformSurface.CreateGlRenderTarget` method can only be called on the UI thread. In normal circumstances this method is called in response to a call to `TopLevel.HandlePaint` from the native `AvnView.updateLayer` method. However, a customer was experiencing a problem where `AvnView.updateLayer` and by extension `TopLevel.HandlePaint` were being called before the window is shown. This broke the creation of the GL render target.
  • Loading branch information
grokys committed Oct 8, 2024
1 parent 89c9702 commit fad06a0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@

_shown = true;
[Window setCollectionBehavior:collectionBehavior];

// Ensure that we call needsDisplay = YES so that AvnView.updateLayer is called after the
// window is shown: if the client is pumping messages during the window creation/show
// process, it's possible that updateLayer gets called after the window is created but
// before it's is shown.
[View.layer setNeedsDisplay];

return S_OK;
}
}
Expand Down

0 comments on commit fad06a0

Please sign in to comment.