Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found a bug when pickr is destroyed before initialization is complete #233

Closed
wants to merge 2 commits into from

Conversation

mardikarifqi
Copy link

@mardikarifqi mardikarifqi commented Jul 23, 2020

I'm now using this library to create a CAD app using Electron. I really appreciate this library due to its easiness to be config'ed. But since my app uses more requestAnimationFrame, FPS kind of become important here.

I found that the constructor is coded using requestAnimationFrame, maybe this is due to get the Pickr offsetWidth. But, if somehow the element was not rendered by the javascript EventLoop and Picker element is destroyAndRemove() for some reason, the constructor will get stuck in an infinite loop of a requestAnimationFrame.

Here is how to reproduce. Open devtools console, then type:

var el = document.createElement('div')
document.body.append(el)
var a = Pickr.create({useAsButton:true, el});
a.destroyAndRemove();

and record the performance profile from chrome dev-tools. You will see a lot of useless 100us requestAnimationFrame call tree.

My solution, give the flag _destroyed and set it to true when destroy() called.

@simonwep simonwep added the bug Something isn't working label Jul 23, 2020
@simonwep
Copy link
Owner

This is somewhat related to #229 - I'll take a look at it in the next days! Thanks for your submission :)

@simonwep
Copy link
Owner

simonwep commented Dec 5, 2020

Confirmed, but keeping the frame-id is cleaner - see f820ed9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants