OS synchronization context #1169
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a mechanism for the runtime to provide a fallback SynchronizationContext. This is needed in scenarios where managed code doesn't necessarily set its own SynchronizationContext and awaits on OS UI thread. .NET runtime makes sure that we end up on the same thread after await, but there was no such mechanism in IL2CPP. Since the way it's handled is highly platform specific, I decided to implement those details in il2cpp OS abstraction layer.
This is one part of the fix for https://fogbugz.unity3d.com/f/cases/1130193/ (another part is in IL2CPP).
Is there anything I can do to minimize the risk of these changes? I made sure Mono builds on katana:
https://katana.bf.unity3d.com/projects/Mono%20Runtime%20and%20Classlibs/builders?krait-signal-handler_branch=master&mono-build-deps_branch=default&mono_branch=os-synchronization-context&boo_branch=unity-trunk&cecil_branch=unity-master&unityscript_branch=unity-trunk&mono-build-tools-extra_branch=master
However, I don't think any tests run there.