-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
How frequently does the bug occur?
Sometimes
Description
When I type on a suggestion in the keyboard, sometimes the UI freezes because of an infinite loop, or I get a Binding<String> action tried to update multiple times per frame.. This happens on the "iPhone SE (1st generation) - iOS 15.0" emulator inconsistently. On my physical device running iOS 15.7.8, it seems to always happen. It doesn't seem to happen for iOS 16.
(UI is frozen after pressing the "Imagine" suggestion)
Stacktrace & log output
There is no crash. I added let _ = print(item.name) and the name keeps being printed.
Imagine Imagine Imagine Imagine Imagine Imagine ...
Can you reproduce the bug?
Sometimes
Reproduction Steps
- Add an item
- Focus on the item
- Select a suggestion on the mobile keyboard
- Sometimes the error doesn't happen on the first try, in which case run the app again
struct ContentView: View {
var body: some View {
ItemsView2()
}
}
import SwiftUI import RealmSwift class Item2: Object, ObjectKeyIdentifiable { @Persisted(primaryKey: true) var _id: ObjectId @Persisted var name: String @Persisted var order: Int } struct ItemsView2: View { @ObservedResults(Item2.self, sortDescriptor: SortDescriptor(keyPath: "order", ascending: true)) var items // maybe the sorting is the cause var body: some View { NavigationView { // List List { Section { ForEach(items) { item in ItemView2(item: item) } .onDelete(perform: $items.remove) // Add Button("Add") { let item = Item2() item.order = (items.max(of: \Item2.order) ?? 0) + 1 $items.append(item) } } } } } } struct ItemView2: View { @ObservedRealmObject var item: Item2 var body: some View { let _ = print(item.name) HStack { // not sure if it makes a difference TextField("Item", text: $item.name) } } }
Version
13.17.0
What Atlas Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
iOS 15
Build environment
Xcode version: 14.3.1
Dependency manager and version: none?