Closed BoysheO closed 2 months ago
I have also briefly reviewed your code, and it seems that SynchronizationContext is a core part of the SDK, rather than just being used to determine whether the current thread is the Unity thread. Therefore, I hope that your SDK can provide an interface that allows me to add my custom SynchronizationContext to a whitelist, so that the error can be ignored.
Or do you need any pull requests?I can make it well.
Hey @BoysheO - definitely reasonable to use thread id instead. Outside of WalletConnect, I don't believe our SDK makes use of SynchronizationContext. We do mess with it in WebGL but I don't think this is relevant to this scenario.
I can speak to the WalletConnect Unity team and have them make that change to their core sdk, subsequently adding it to our sdk.
Feel free to make a PR regardless
see https://github.com/thirdweb-dev/unity-sdk/pull/216.Keep all things simple.
See file WalletConnect.cs line 72. SDK version=v5.2.1 In fact, our client modifies Unity's default SynchronizationContext to achieve better performance, which is a very common practice in commercial games. Therefore, do not use SynchronizationContext to determine whether the current logic is running on the main thread. A more mature approach is to retrieve the current thread's ID in the Awake function of a MonoBehaviour, and use this to check if other asynchronous contexts are on the main thread.