-
Notifications
You must be signed in to change notification settings - Fork 168
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
Update Starscream dependency to Major 4.x.x version. #81
Conversation
swift-nio-zlib-support subdependency removed. Public WC interface was not affected.
Just saw another 2 MRs :/ Will checkthem instead. |
…equest for session have been sent
…y cycles inside of Client -> onCallback -> WebSocketConnection -> Client. Still this gives a better control for demo apps to do intended job.
Additional tests required for NativeEngine Hacked in solution for iOS platform.
Made a proof of work for TCPTransport custom WSEngine iOS 12.0+ Most likely we need to inject state from the outside, especially if we still want to guarantee iOS 11 support. I, personally, do not see much sense in that iOS 11 support, better to spend time of MR to Starscream to make NativeEngine work as expected. |
It all works great until I try to connect with MetaMask. This thing is just something. Trust/Argent/Rainbow - work except Metamask. |
Looks like a problem in the new engine implementation. If we pass Basically it is fallback to the old Starscream implementation. |
…of the sockets without background capabilities
… retained by WalletConnect class. That would not allow to follow RAII principle. So if I release WalletConnect instance - my sockets would still remain active, which is not expected
#if os(iOS) | ||
if let observer = self.backgroundNotificationObserver { | ||
NotificationCenter.default.removeObserver(observer) | ||
} | ||
if let observer = self.foregroundNotificationObserver { | ||
NotificationCenter.default.removeObserver(observer) | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if os(iOS) | |
if let observer = self.backgroundNotificationObserver { | |
NotificationCenter.default.removeObserver(observer) | |
} | |
if let observer = self.foregroundNotificationObserver { | |
NotificationCenter.default.removeObserver(observer) | |
} | |
#endif |
I think there's no need to call removeObserver in deinit
(https://developer.apple.com/documentation/foundation/notificationcenter/1413994-removeobserver)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking!
I actually see the opposite example in:
https://developer.apple.com/documentation/foundation/notificationcenter/1411723-addobserver
And it is logical in a sense that somebody who registers to notifications holds the reference and has control over it.
Am I missing something?
#if os(iOS) | ||
private var backgroundNotificationObserver: Any? | ||
private var foregroundNotificationObserver: Any? | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to retain observers since the observation will exist for the duration of this class
#if os(iOS) | |
private var backgroundNotificationObserver: Any? | |
private var foregroundNotificationObserver: Any? | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically you're right, as blocks does not capture self
, still, it will let our blocks passed to NotificationCenter be alive for an undefined amount of time. And contradicts the RAII principle, and leaves hanging memory in heap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.apple.com/documentation/foundation/notificationcenter/1411723-addobserver
The block that executes when receiving a notification.
The notification center copies the block. The notification center strongly holds the copied block until you remove the observer registration.
The block takes one argument: the notification.```
@DmitryBespalov Is there anything that might need help to resolve this MR? |
HI @zulkis apologies for resurfacing this old thread. I'm trying to reproduce the issues you mentioned above with Metamask (see this issue for context), and the only way I can is when using WalletConnectSwfit's example Client and the Metamask iOS app, both installed on the same iPhone. In this scenario I do see the socket disconnected errors, but AFAIK that's simply because either app will likely close/disconnect its sockets automatically once moved to background. If instead I use two different devices (or device for Metamask and simulator for Client) then it works fine, and also does with the native socket engine. Can you confirm whether this is what you were seeing or was your use case something different perhaps? |
Hi @oscahie, First of all - this pattern you've mentioned is one of the most important, in my opinion, as if my app and my wallet are on the same device - how else can I connect it? I pretty much agree with everything what you've said in original proposal: I believe Best solution would be to stop using StarScream altogether as it is full of known and visible bugs(Specifically bottom part of transport layer) and unsupported for quite a long time. Even in that case I do not see how it will help resolving
Because this is low level error from OS itself and looks like that happens because of inner conflict between usage Metamask app(Which heavily uses WS) and client on the same device. What I had as well experienced - is that I was losing whole network access on iPhone + MacOS(sic) when I have debugger attached to my app with WalletConnect library with Xcode and network as well was off on mac. I could not fully remember all the details as my focus shifted last months but if you'd have specific questions - happy to help. |
Ok, that's a very fair point. I agree that both apps on the same device should be a supported scenario, and I have an idea to hopefully make it work with the native websockets engine too. I'm working on it, will ping you again when I have something to show. |
swift-nio-zlib-support subdependency removed.
Public WC interface was not affected.