hi i have problem with my realtime subscription somone can help ? all i did is to write subscription func and call the realtime.subscribe
Is this cloud or self-hosted?
cloud
Could you please share the full code?
i removed a lot of code to debug this and here is the minimum code for the data race error to show i have manager variable inside the MainCV view and when the page is appear im triggering the subscriptions(realtime) method and thats making the data race (error)
?
I practically didn't have used Swift, but this doesn't look like an error?
its data race leak -> two different threads (main,global) running the same thing (web-socket connect), its only happening when triggering one of the realtime appwrite subscription methods from the (appwrtie - swift - sdk), and sometimes its crashing the app. from my research i pretty sure its bug inside the Appwrtie Realtime Libary so how we can overcome this ?
how do i turn on xcode thread sanitizer tool? I don't use Xcode so i don't know where anything is 😬
nvm i think i found it
soooo where exactly do you see the error? I see
i tested using this repo: https://github.com/appwrite/playground-for-apple-uikit
i subscribed and then went to the console and deleted a document in my collection
i made a new SwiftUI project for reproduce the error for you on blank project this is the easy steps i did
- turn on thread sanitizer tool click on app icon -> edit scheme -> diagnostics -> thread sanitizer tool
- add Appwrtie class with subscribe method same as the Appwrtie apple doc
- make appwrite state variable inside the ContentView and call the subscribe method from it run the app and you can see the data race problem
im using SwiftUI not UIKit and i find out its showing from Appwrite version 2.0.0 until today version... the fastest way to see what im talking about you you can use https://github.com/appwrite/playground-for-apple-swiftui just change the Appwrite version above 2.0.0 and turn Thread sanitizer tool on
thanks! ill take a look
are you saying the problem is not present in version 1.2.3 of the SDK?
hey Steven i tried 1.0.0 and didn't saw the issue and 2.0.0 and above i saw it i now checked specific for version 1.2.3 of the SDK with https://github.com/appwrite/playground-for-apple-swiftui when clicking on subscribe the data race Appears
thanks for the insight! The only thing i found related between 1.0.0 and 1.2.3 was this: https://github.com/appwrite/sdk-for-apple/pull/28/files#diff-004b903953dedf993743db9d8325f4ddf63abe7a51fbee81f243e9216ca22e7e
i see i don't understanding why it's happened from the changes you shared from the console what i see is some data write and the heap block allocated from thread 2 and the same data read from thread 1 i guess in the same time because its data race issue Hopefully we can trace it because i don’t think its will pass the Apple App Store check
Honestly, I'm not sure either since I don't know too much about swift...let me see if anyone else on the team does
hey steven any updates from anyone on the team is familiar with swift? i think it's critical for the Appwrite Apple SDK to work well for swift developers to use it
Hey, sorry you're having trouble with the SDK, a few questions first off:
- Have you tried with the latest version of the SDK (4.0.2)?
- Have you tried calling from a
class
instead of anactor
? (subscribe
is a synchronous method) - Which version of Xcode are you using?
- Have you recently updated Xcode?
- Does this warning trigger for both simulators and physical devices?
hey Jake, firstable my answers is -> 1,2,4) all yes 3) my xcode Version is 15.1 5) with physical device we can’t unable the thread saintizer tool, i checked with https://github.com/appwrite/playground-for-apple-swiftui for easier way for you to reproduce it just turn on the thread saintizer tool and change to the latest swift sdk version.
i think its important to understand only when turn on this tool the problem is showing. this is tool is created for trace data race issues and the only method in the SDK trigger the issue is the subscribe method i think if someone on the team is familiar with the WebSocket file inisde the swift sdk will see the error it will be more easier to understand what why its popping hey Jake, firstable my answers is -> 1,2,4) all yes 3) my xcode Version is 15.1 5) with physical device we can’t unable the thread saintizer tool, i checked with https://github.com/appwrite/playground-for-apple-swiftui for easier way for you to reproduce it just turn on the thread saintizer tool and change to the latest swift sdk version.
i think its important to understand only when turn on this tool the problem is showing. this is tool is created for trace data race issues and the only method in the SDK trigger the issue is the subscribe method i think if someone on the team is familiar with the WebSocket file inisde the swift sdk will see the error it will be more easier to understand what why its popping
Recommended threads
- Error: User (role: guests) missing scope...
I want to send a verification code to the user and the given phone number and check it and create a session right after the user entered the secret. For me that...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...