#8157·capacitor

[错误]: CAPPlugin 事件处理在 iOS 上导致数据竞争

作者: gjb-amazon创建于 2025年9月15日更新于 2026年9月17日
标签needs reproduction

import Capacitor import XCTest final class CAPPluginSynchronizationTest: XCTestCase { func testConcurrentAccess() { let plugin = CAPPlugin() // Need to assign this since it's not assigned in CAPPlugin's initializer, otherwise we're just messaging nil everywhere and not actually showcasing the data race. plugin.eventListeners = [:] let group = DispatchGroup() let iterations = 1000000 for i in 0..<iterations { group.enter() let listener = { (event: CAPEvent) in print("Event: (event)") } plugin.notifyListeners(listener, "Hello World!", true) group.leave() } group.wait() } }

内容来源: ionic-team/capacitor