Skip to content

State not reflected when there is no user input #23

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

Closed
dluksza opened this issue Jan 11, 2020 · 4 comments · Fixed by #24
Closed

State not reflected when there is no user input #23

dluksza opened this issue Jan 11, 2020 · 4 comments · Fixed by #24
Labels
bug Something isn't working

Comments

@dluksza
Copy link

dluksza commented Jan 11, 2020

When setState is called from code instead of on user action (like mouse click or screen tap), first execution is not reflected in the UI.

Here is counter project modified to automatically increment counter value every 2s: https://github.com/dluksza/flutter_auto_refresh

On android emulator everything works fine UI shows 0, 1, 2, 3, 4, 5 etc. every 2s. But when the same code is run using flutter-pi on Rpi3 it shows 0, 2, 4, 6 etc every 4s. whereas on console values 1, 2, 3, 4 etc. are printed every 2s.

This also means that other automatic UI updates will not be reflected until another setState is called.

@ardera
Copy link
Owner

ardera commented Jan 12, 2020

That's interesting. I actually think this is not caused by the missing user action, but because of some kind of bug in the vsync-waiter. Could be that somehow frames get dropped when no other frames are scheduled at that moment, or somehow 2 frames get drawn immediately after each other, so that the first one isn't visible.

If you press the action button to increment the counter, there's a bunch of frames being rendered so one wouldn't notice if a few were missing.

I'll look into it

@ardera ardera added the bug Something isn't working label Jan 12, 2020
@ardera ardera mentioned this issue Jan 12, 2020
@ardera
Copy link
Owner

ardera commented Jan 12, 2020

Implemented vsync some time ago, just forgot to upload it. oops
that vsync code changed rendering a lot, and seems like one of these changes has fixed the bug.

@dluksza
Copy link
Author

dluksza commented Jan 12, 2020

Thank you! Can confirm this is fixed on latest master :)

@dluksza
Copy link
Author

dluksza commented Jan 14, 2020

Unfortunately this seems to break touch on my monitor. FAB in the counter app doesn't work anymore. Going back to commit 530049f fixes the with tap, but then setState doesn't work :|

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 a pull request may close this issue.

2 participants