# Defer drawing the window until the CoreAnimation \`displayLayer:\` method is called \(\#3592\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/f12510b8b0b43e4894c228e30df402e0190df00c)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: f12510b8b0b43e4894c228e30df402e0190df00c

Requested commit: f12510b8b0b43e4894c228e30df402e0190df00c

Commit: f12510b8b0b43e4894c228e30df402e0190df00c

Tree: 91de18caf0f63b5fc70cb9db970e1d6f47bf439b

Author: Max Brunsfeld

Committer: GitHub

## Message

```
Defer drawing the window until the CoreAnimation `displayLayer:` method is called (#3592)

GPUI (both 1 and 2) currently performs rendering, layout, and painting
at the end of every effect cycle. This leads to poor performance when
the app receives events more frequently than the display refreshes. Such
rapid events can come from a terminal, an LSP, or a mouse with a high
polling rate.

This PR changes GPUI so that we don't render until the OS notifies us
that the content will be presented, via the `displayLayer:` callback.

Because render, layout, and paint have side effects that are sometimes
relied on in tests, we currently keep the old behavior (drawing after
every effects cycle) in tests.

This is similar to what @ForLoveOfCats explored in
https://github.com/zed-industries/zed/pull/3542, but slightly simpler,
in that we're not using the display link. As a follow-up, we could use
the display link to start rendering earlier, to possibly reduce latency
further.
```

## Parents

- [41f55e4d0d7297da6e19e9bfa28a8128f55a0c6b](https://git.cafe/gitcafe/zed/commit/41f55e4d0d7297da6e19e9bfa28a8128f55a0c6b?format=markdown)

- [fdcb413e3321960a80634db310e28520713c3cba](https://git.cafe/gitcafe/zed/commit/fdcb413e3321960a80634db310e28520713c3cba?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/f12510b8b0b43e4894c228e30df402e0190df00c?format=markdown)
