funwithflutter/flutter_confetti

Sporadic confetti even though random hasn't been chosen

Closed this issue · 8 comments

We're noticing in our dev builds using the Confetti package that the number of confetti as well as the number of times it bursts is sporadic. Sometimes it bursts fine with confetti, other times it jitters when it bursts, and sometimes there isn't any confetti at all. Here's how we're using the confetti:

Align(
            alignment: Alignment.center,
            child: ConfettiWidget(
              confettiController: _controllerCenter,
              blastDirectionality: BlastDirectionality.explosive,
              emissionFrequency: 0.05, // how often it should emit
              numberOfParticles: 10, // number of particles to emit
              gravity: 0.05, // gravity - or fall speed
              shouldLoop: false,
            ),
          ),

This might be more of a documentation issue, than the package. I should be clearer about the use of the different properties.

You want to take a look a the emissionFrequence - which determines the likelihood of the confetti emitting. You have it set to 0.05, meaning 5% chance of emitting on a single frame.

For each animation frame the confetti has a likelihood of emitting - maybe it will maybe it won't. The higher you set the emissionFrequence, the more likely it will emit. So if you set it to 1, then it will definitely emit every single frame. But beware there might be 60 frames per second, or more, or less.

I've been considering changing this behavior. But part of the appeal of confetti is that it should be sporadic and not a constant stream.

But that said you can make a constant stream by setting
emissionFrequency to 1
and maybe limiting the numberOfParticles to only 1.

Play with these two properties to achieve your desired effect. Please let us know if that works for you and I'll close this issue.

Hi @funwithflutter, thank you for your informative response. I had a feeling this may have been the case, since I didn't see anyone else mentioning this issue and it would be a pretty big problem if it was occurring on a wider scale. I'll implement the changes you suggested to see if I can get it to consistently confetti, and reply on here once it's confirmed so you can close the ticket. Thanks!

Hi @funwithflutter, we were able to get a pretty nice and constant stream setting emissionFrequency to 0.5 and numberOfParticles to 2 :) Appreciate your help!

Actually, sorry–wanted to reopen this really quick to ask about one thing. We're noticing that when the confetti is triggered, it tends to "explode twice", is there a reason for this or a way to set it? We would ideally have it only explode once. The strange thing is sometimes it does explode once but often it does like a single short spurt and then explodes again. Let me know if you need any more info @funwithflutter !

Actually, sorry–wanted to reopen this really quick to ask about one thing. We're noticing that when the confetti is triggered, it tends to "explode twice", is there a reason for this or a way to set it? We would ideally have it only explode once. The strange thing is sometimes it does explode once but often it does like a single short spurt and then explodes again. Let me know if you need any more info @funwithflutter !

I would need to investigate this. It might just be chance or there might be a logic flaw. I'll be revisiting this package soon, to see what improvements I can make, then I'll see if I can replicate this behavior.

Actually, sorry–wanted to reopen this really quick to ask about one thing. We're noticing that when the confetti is triggered, it tends to "explode twice", is there a reason for this or a way to set it? We would ideally have it only explode once. The strange thing is sometimes it does explode once but often it does like a single short spurt and then explodes again. Let me know if you need any more info @funwithflutter !

I would need to investigate this. It might just be chance or there might be a logic flaw. I'll be revisiting this package soon, to see what improvements I can make, then I'll see if I can replicate this behavior.

That would be great, thank you! The package is an awesome one and I really appreciate you putting it out there for the world to use :)

New version is released, I didn't do a lot of investigation regarding your issue. I believe it is just the way the package is implemented. It's all based on chance, sometimes it shoots, sometimes not. But in the future when I do an overhaul I will add some features to ensure it definitely emits on the first frame (so stay on the look out for that).

BUT, I made some huge performance improvements to the new version. It should be a lot smoother, plus possible to add a lot more confetti without having to worry about jank. In theory it should also work better if your app has a lot of painting happening in the backgrounds (a complex UI).

Please let me know if you can see a performance improvement on your side.

The package now emits on the first frame 4913a69, regardless of other configurations. So this should have a better overall look to how the confetti widget behaves. Closing this issue for now.