-
Notifications
You must be signed in to change notification settings - Fork 43
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
IOS-5674 Fix reader #338
IOS-5674 Fix reader #338
Conversation
@@ -246,7 +246,7 @@ public class CardSession { | |||
/// - Parameter error: The error to show | |||
public func stop(error: Error, completion: (() -> Void)?) { | |||
Log.session("Stop session") | |||
reader.stopSession(with: error.localizedDescription) | |||
reader.stopSession(with: error) |
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.
Добавил интерфейс, чтобы доносить до калльбэков правильную ошибку. Сейчас тип теряется и постится userCancelled во всех случаях, например, если происходит остановка по тайм-ауту тэга
Log.nfc("Restart polling interval is: \(interval)") | ||
|
||
// 20 is too much because of time inaccuracy | ||
if interval >= 18 { | ||
if interval >= 16 { |
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.
пришлось сократить до минимума, иначе session invalidated unexpectedly
@@ -371,12 +401,11 @@ extension NFCReader: CardReader { | |||
.TimerPublisher(interval: Constants.tagTimeout, tolerance: 0, runLoop: RunLoop.main, mode: .common) | |||
.autoconnect() | |||
.receive(on: queue) | |||
.filter {[weak self] _ in self?.idleTimerCancellable != nil } |
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.
из-за этой строки, этот таймер вообще не работал и не останавливал сессию. Это суть фикса номер 1
invalidatedWithError = stoppedError ?? TangemSdkError.parse(error as! NFCReaderError) | ||
} | ||
|
||
if let tagConnectionTS { |
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.
анврапится только одно значение, второе не optional, но все равно загнал под один if для единообразия
|
||
self.tagConnectionTS = Date() | ||
|
||
if self.firstConnectionTS == nil { |
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.
судя по экспериментам, тут правильнее это держать
return | ||
} | ||
|
||
isBeingStopped = true |
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.
Суть фикса номер 2. Вводится эта переменная, которая помогает отфильтровать ненужные сообщения.
@@ -400,6 +429,7 @@ extension NFCReader: CardReader { | |||
.TimerPublisher(interval: Constants.idleTimeout, runLoop: RunLoop.main, mode: .common) | |||
.autoconnect() | |||
.receive(on: queue) | |||
.filter { [weak self] _ in !(self?.isBeingStopped ?? true) } |
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.
При анализе кейсов и логов добавил фильтрацию и тут
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.
так по мелочи комменты
слегка подправил, QA потестировали, все ок |
Репорт в том, что плашка NFC либо закрывалась сама без каких-либо сообщений, либо с ошибкой, но слишко быстро. https://tangem.atlassian.net/browse/IOS-5674
Непосредственно баг из-за изменения поведение каллбэков от NFC-слоя, пришлось расставить больше костылей.
Тестировал на разных девайсах и осях, нигде не оторвало, поэтому не стал расставлять ифы по версиям
TODO: Взять в работу рефакторинг ридера, он очень сложный, события поступают с разных источников, может нужна архитектура в стиле редукса.