Skip to content

Commit 36ab7db

Browse files
committed
refactor(ios): hoist MMKV read out of bridgeStateQueue in getLastVoipToken
Keep disk I/O outside the critical section so a slow MMKV read cannot block main-thread token updates. Second sync re-checks lastVoipToken to handle concurrent reloaders.
1 parent d320e19 commit 36ab7db

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

ios/Libraries/VoipService.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,14 @@ public final class VoipService: NSObject {
229229
/// Returns the last registered VoIP token
230230
@objc
231231
public static func getLastVoipToken() -> String {
232-
bridgeStateQueue.sync {
232+
let current = bridgeStateQueue.sync { lastVoipToken }
233+
if !current.isEmpty {
234+
return current
235+
}
236+
let persisted = loadPersistedVoipToken()
237+
return bridgeStateQueue.sync {
233238
if lastVoipToken.isEmpty {
234-
lastVoipToken = loadPersistedVoipToken()
239+
lastVoipToken = persisted
235240
}
236241
return lastVoipToken
237242
}

0 commit comments

Comments
 (0)