I have a timer scheduled as following:
private var timerCancellable: Cancellable?
timerCancellable = Timer
.publish(every: 1.0, on: .current, in: .common)
.autoconnect()
.scan(-1) { counter, _ in counter + 1 }
.sink { counter in
print("\(counter)")
}
This works fine (print out 0 1 2 3 ...) when I test it on any normal view controller. But in a specific view controller which I a live camera feed with Metal shaders (and several different DispatchQueue instances), it gives this output:
0 0 1 2 3 ...
0 is repeated twice. I tried .main for RunLoop but the result is the same. Can anyone help?