Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Fix obscure Chrome setTimeout issue #447

Merged
merged 4 commits into from
Mar 12, 2019
Merged

Conversation

atomiks
Copy link
Owner

@atomiks atomiks commented Mar 11, 2019

Ok so this is weird..

I originally used delay: [0, 20] as the default because Chrome had this transitionend issue where it fires 1 frame too late sometimes. It's not a memory leak or bug, just an aesthetic thing.

Using a delay of 20ms fixed the following: When mousing out of the element 1 frame before the tooltip fully showed, it would instantly be unmounted without transitioning out. When mousing in and out of the tooltip quickly it would sometimes unmount instantly rather than smoothly transition out (like interruptible animations should). It's not that big of a deal but kind of bothered me.

However now there's this strange bug where the hide setTimeout gets fired really late despite only being 20ms by default. Like 1500ms+ and it leaves the tooltip stuck on the UI for a bit. And it's really hard to reproduce because it only happens 1/50 times or so, requires a page refresh, etc. It might even be something to do with Gatsby.

I tested and confirmed that the timeout callback is being fired very late. I only found this issue https://stackoverflow.com/questions/35102791/stuck-settimeouts-chrome


What this change does is remove setTimeout scheduling by default and instead use requestAnimationFrame which doesn't seem to suffer from the late scheduling problem. This won't fix the late scheduling when you set a non-zero hide delay though...

@atomiks atomiks merged commit e1b7bae into master Mar 12, 2019
@atomiks atomiks deleted the chrome-settimeout-issue branch March 12, 2019 04:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants