Skip to content

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