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

A worker is always created #131

Closed
fungiboletus opened this issue Nov 6, 2020 · 2 comments
Closed

A worker is always created #131

fungiboletus opened this issue Nov 6, 2020 · 2 comments
Labels
question Further information is requested

Comments

@fungiboletus
Copy link

Hi,

Thanks for your library, it's great !

I use it on an application with some strict Content Security Policy, disallowing web workers from blobs. It works because it fails back to the no worker version, and I can also specificy useWorker to false with the create function.

However the library always attempt to create a worker because its default function uses a worker. Do you think it could be possible to not create this worker without braking the API ?

@catdad catdad added the question Further information is requested label Nov 15, 2020
@catdad
Copy link
Owner

catdad commented Nov 16, 2020

I did address this here: #112 (comment)

TL;DR: The current behavior, including the error you see, is intended behavior. It is necessary to provide the best performance in most situations. More specifically, here are the specific considerations:

  • a user without any sort of CSP: this user should have the optimal performance.
  • a user that sets an aggressive CSP that disables workers in this module: this user needs to know that they have inadvertently compromised the performance of this module as well as the performance of their web application. This user needs to know this happened so that they may fix it.
  • a user with with CSP that they actually need that disables workers in this module: well... this will happen. It is rare, but it can happen and I understand. This user still needs to know that they have compromised the performance of their web application. The error that see does not impede usage of this module or execution of their application (the error is handled). Until a time that there is an API that lets modules query CSP at runtime, this error is a necessity.

@fungiboletus
Copy link
Author

Alright.

I'm not a fan of having an error in the console by default but I understand your choices.

By the way I modified the library to remove the web worker code and to use a dynamic framerate with requestAnimationFrame. Even though it wasn't using a webworker, the framerate improved a lot with a normal amount of particles . Instead of the fixed 60hz, it used the framerate provided by the web browser, which is slower when the machine is slow and faster when the screen is faster (240hz on my laptop which did produce much smoother animations).

liamcmitchell-sc added a commit to liamcmitchell-sc/canvas-confetti that referenced this issue Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants