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

fix: First event being missed in iOS background worker #188

Merged
merged 2 commits into from
Dec 17, 2023

Conversation

mchudy
Copy link
Contributor

@mchudy mchudy commented Dec 6, 2023

I noticed a problem with the execution of the HomeWidgetBackgroundWorker. The first tap on my widget's button wouldn't execute the Dart callback the first time it had been called (with the app being terminated). I believe the if condition in run should be the other way around:

  • if the setup is completed and the FlutterEngine is started we can send the event directly to the MethodChannel.
  • if the setup is not yet completed we should add the event to the queue and when the background is initialized (HomeWidget.backgroundInitialized is received) the queue will be emptied and the event send to the existing method channel.

I'm also not sure if we need to get the dispatcher here and log it, but I leave it for you to decide.

@ABausG ABausG changed the title Fix first event being missed in iOS background worker fix: First event being missed in iOS background worker Dec 6, 2023
Copy link

codecov bot commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3a1976c) 100.00% compared to head (e741465) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #188   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           69        69           
=========================================
  Hits            69        69           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@ABausG ABausG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! I actually noticed that this had issues but did not see that basically the actions in the if block where the wrong way around. I guess this might also fix #179 ?

@mchudy
Copy link
Contributor Author

mchudy commented Dec 6, 2023

Not sure about that, what I'm currently doing is using background tasks to prevent the app from stopping, but I don't know if this should be the default behavior. #176 (comment)

@ABausG ABausG merged commit 867c435 into ABausG:main Dec 17, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants