Open Ciyou opened 1 year ago
Has anyone found a solution for this? I struggled with this issue in my app, I can't seem to find a way to get rid of the crash, which happens super often ~95% (but strangely not always, sadly I can't notice any pattern that could tell me why it doesn't crash 5% of the time)
How frequently does the bug occur?
Almost always in my personal project, more than 95%
Description
I'm using realm swift in a SwiftUI project. In the project I have a view contains an
ObservedRealmObject
and passes it to multiple subviews, both subview also reference the object as anObservedRealmObject
. When I dismiss the parent view, the app always crash due to trying to remove an observer before it's registered as an observer.I wrote a minimal demo project to reproduce the crash.
Stacktrace & log output
Can you reproduce the bug?
Always (with demo code below)
Reproduction Steps
To reproduce the bug:
I personally think it's caused by having a
ObservedRealmObject
passing down to more than one subview, and some borken logic cause the value observed only once.Version
10.41.1
What Atlas Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
both iOS 16 and iOS 17, can be reproduced on both Xcode 14 and Xcode 15
Build environment
Xcode version: can be reproduced on both Xcode 14 and Xcode 15 Dependency manager and version: SPM bundled with Xcode