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

CPU usage spike after upgrading to 3.0.0 #748

Closed
liri2006 opened this issue Dec 28, 2019 · 11 comments
Closed

CPU usage spike after upgrading to 3.0.0 #748

liri2006 opened this issue Dec 28, 2019 · 11 comments
Assignees
Labels
bug Something isn't working dependency This issue has an external dependency
Projects
Milestone

Comments

@liri2006
Copy link

Describe the bug
After upgrading flutter_bloc to 3.0.0 (and rxdart to 0.23.1) I've noticed slight spike in CPU usage by Android Emulator (qemu-system-x86_64.exe process, Windows 10). Immediately after starting the app CPU usage jumps to 40+% and just stays there even though app does nothing.
If downgraded back to 2.1.1 (rxdart to 0.22.0) and restarting the app it falls to 4-5% and everything is ok.

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade flutter_bloc to 3.0.0 and rxdart to 0.23.1
  2. Start the app
  3. Check CPU usage in task manager

Expected behavior
CPU usage stays low.

Paste the output of running flutter doctor -v here.

[√] Flutter (Channel beta, v1.12.13+hotfix.6, on Microsoft Windows [Version 10.0.17763.914], locale en-US)
• Flutter version 1.12.13+hotfix.6 at C:\flutter
• Framework revision 18cd7a3601 (2 weeks ago), 2019-12-11 06:35:39 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\amunk\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.

[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.41.1)
• VS Code at C:\Users\amunk\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.7.1

[√] Connected device (1 available)
• AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!

@felangel
Copy link
Owner

Hi @liri2006 👋
Thanks for opening an issue!

This is more likely a Flutter issue than a bloc issue as bloc v3.0.0 requires Flutter >=v1.12.1. Are you able to compare a counter app with setState and a counter app with bloc to see if the CPU spike only occurs in the bloc variant? Thanks!

@felangel felangel self-assigned this Dec 28, 2019
@felangel felangel added question Further information is requested waiting for response Waiting for follow up labels Dec 28, 2019
@felangel felangel added this to To do in bloc via automation Dec 28, 2019
@liri2006
Copy link
Author

Well, I did compare counter app with and without bloc... and both did not have any issues. And also I'm not able to reproduce it in my main app anymore, so guess it was somehow related to stars alignment, time of a day or just my computer was angry with me for some reason. Sorry for bothering you!

bloc automation moved this from To do to Done Dec 28, 2019
@tenninebt
Copy link

Hi, noticed the same thing, actually I upgraded from 1.0.0 to 3.0.0 and encountered the issue. Pretty sure it does not come from Flutter and here is why : I checked my pubspec.lock "without upgrade" vs "with upgrade" of flutter_bloc and I have noticed that my SDK version was already 1.12.13+hotfix.4 in both cases, the only upgrades that happened were :

  • bloc 1.0.1 -> 3.0.0
  • rxDart 0.22.6 -> 0.23.1
  • provider 3.2.0 -> 4.0.0
  • a new dependency : nested 0.0.4

I didn't have time to do further investigations. (Don't have my usb-c adapter with me to profile on device)

@liri2006 liri2006 reopened this Dec 28, 2019
bloc automation moved this from Done to In progress Dec 28, 2019
@liri2006
Copy link
Author

@tenninebt Can you try to downgrade to flutter_bloc 2.1.1 and rxdart 0.22.0? That's what helped me in the morning. Btw, I was initially updating from flutter_bloc 0.21.0.

@felangel
Copy link
Owner

felangel commented Dec 28, 2019

I am skeptical that bloc is the issue because there were no major changes to bloc itself. Most of the big changes were in provider and rxdart. If you can provide detailed reproduction steps and have good reason to suspect bloc I'm happy to look into it but given the changes it wouldn't make sense to me.

@tenninebt
Copy link

@felangel I totally understand, that's why I said it is one of the upgrade that comes with bloc (could be rx or provider).
@liri2006 I did downgrade to 2.1.1 which solves the issues (same as downgrading to 1.0.0).
I'll have a look asap, probably next week and I'll post my findings.

@tenninebt
Copy link

Just had a look at provider repository, I think we have a winner : rrousselGit/provider#308
The fix is live (4.0.1), it does fix the issue. I guess for the next release, the dependency should be to >=4.0.1.

@tenhobi
Copy link
Collaborator

tenhobi commented Dec 28, 2019

The dependency should be fine then.

flutter_bloc uses provider: ^4.0.0, which is also suitable for 4.0.1. Just be sure to update your dependencies again to fetch those changes I guess. :-)

@tenninebt
Copy link

What I meant is as long as the version is not explicitly constrained, there a risk of other people facing the issue, (if they have an explicit 4.0.0 direct dependency I guess, but maybe in other cases too), forcing the dependency to be ^4.0.1 is safer as they either will have the right version or a conflict when getting the packages, it is clearly not urgent, but nice to have on a next version.

@felangel
Copy link
Owner

I'll include this in v3.1.0 👍

@felangel felangel added this to the v3.1.0 milestone Dec 28, 2019
@felangel felangel removed the waiting for response Waiting for follow up label Dec 28, 2019
@felangel felangel added bug Something isn't working dependency This issue has an external dependency and removed question Further information is requested labels Dec 29, 2019
@felangel
Copy link
Owner

felangel commented Jan 1, 2020

Published in flutter_bloc v3.1.0 🎉

@felangel felangel closed this as completed Jan 1, 2020
bloc automation moved this from In progress to Done Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependency This issue has an external dependency
Projects
bloc
  
Done
Development

No branches or pull requests

4 participants