# gpui: Update animated image timing to pause when inactive \(\#52685\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 086060558f9c6cdb802deac64f2fbde243986bb6

Requested commit: 086060558f9c6cdb802deac64f2fbde243986bb6

Commit: 086060558f9c6cdb802deac64f2fbde243986bb6

Tree: a1a5701fa0903d885506e5fceb6245045c630412

Author: MostlyK

Committer: GitHub

## Message

```
gpui: Update animated image timing to pause when inactive (#52685)

- only advance frames and request animation frames while the window is
active.
- Reset last_frame_time to None when inactive to avoid fast catch-up
after resuming focus
- This fixes an issue where if you would have a gif open and lose focus,
the app tries to speedup to catch up the elapsed time


Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Might Close #21563, I shall measure the performance, I originally only
intended the fix to fix the speed up issue as I faced it while working
on gifs.


Release Notes:

- N/A or Added/Fixed/Improved ...
```

## Parents

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

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