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

Work around Unity's async cancellation #246

Merged
merged 2 commits into from
Oct 11, 2024
Merged

Conversation

sbergen
Copy link
Owner

@sbergen sbergen commented Oct 11, 2024

Under certain circumstances, task cancellation in Unity will happen later in the same frame, instead of synchronously.

Due to this, state strings during errors often get updated only after the error has been propagated, causing them to be waiting ([.]) instead of canceled ([-]). This also caused the tests for Unity to have to be slightly different from .NET tests.

To work around this, we can await Task.Yield() before propagating errors.

It caused some breaking changes in RunAsLoop, which can no longer be synchronous, so I'm starting a v5 branch now, as there are other breaking changes I'd also like to make.

Copy link

codecov bot commented Oct 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.90%. Comparing base (2131c5d) to head (f02afb5).
Report is 1 commits behind head on v5-base.

Additional details and impacted files
@@             Coverage Diff             @@
##           v5-base     #246      +/-   ##
===========================================
- Coverage   100.00%   99.90%   -0.10%     
===========================================
  Files          116      116              
  Lines         2177     2183       +6     
  Branches       111      113       +2     
===========================================
+ Hits          2177     2181       +4     
- Misses           0        2       +2     
Flag Coverage Δ
Unity2021.3.27f1 99.85% <100.00%> (-0.15%) ⬇️
Unity2022.3.2f1 99.85% <100.00%> (-0.15%) ⬇️
netstandard 99.94% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@sbergen sbergen force-pushed the FixUnityAsyncCancellation branch from ff85c20 to f02afb5 Compare October 11, 2024 19:27
@sbergen
Copy link
Owner Author

sbergen commented Oct 11, 2024

The missing code coverage is on closing curly braces, and looks like some weirdness caused by an added await inside a catch. Couldn't figure out anything that could be done about it, so ignoring it now. 100% coverage would be nice, but this doesn't seem worth working around.

@sbergen sbergen merged commit 39f1ace into v5-base Oct 11, 2024
13 of 14 checks passed
@sbergen sbergen deleted the FixUnityAsyncCancellation branch October 11, 2024 20:20
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.

1 participant