From fe87127270cf81d2bbe7b4f93349f8b1cf795540 Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Mon, 25 Nov 2024 11:54:18 -0300 Subject: [PATCH 1/2] Improve an precondition failure message --- Sources/AblyChat/RoomLifecycleManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/AblyChat/RoomLifecycleManager.swift b/Sources/AblyChat/RoomLifecycleManager.swift index 043602c2..ff164d7e 100644 --- a/Sources/AblyChat/RoomLifecycleManager.swift +++ b/Sources/AblyChat/RoomLifecycleManager.swift @@ -463,7 +463,7 @@ internal actor DefaultRoomLifecycleManager Date: Mon, 25 Nov 2024 10:05:37 -0300 Subject: [PATCH 2/2] Change criteria for deciding if discontinuity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an intermittent crash ("Non-initial ATTACHED state change with resumed == false should have a reason") in the integration tests which happened because the manager sometimes processed the initial ATTACHED contributor state change after the `attach()` call completed. I’ve followed my first suggestion in [1] for how to address this. Resolves #121. [1] https://github.com/ably/specification/issues/239 --- Sources/AblyChat/RoomLifecycleManager.swift | 10 +++++--- .../DefaultRoomLifecycleManagerTests.swift | 23 ++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Sources/AblyChat/RoomLifecycleManager.swift b/Sources/AblyChat/RoomLifecycleManager.swift index ff164d7e..67cdcff4 100644 --- a/Sources/AblyChat/RoomLifecycleManager.swift +++ b/Sources/AblyChat/RoomLifecycleManager.swift @@ -164,6 +164,7 @@ internal actor DefaultRoomLifecycleManager Void' passed as a strongly transferred parameter; later accesses could race" go away. I don’t hugely understand what it means, but given the "'self'-isolated value" I guessed it was something vaguely to do with the fact that `async` actor initializers are actor-isolated and thought that marking it as `@Sendable` would sever this isolation and make the error go away, which it did 🤷. But there are almost certainly consequences that I am incapable of reasoning about with my current level of Swift concurrency knowledge. group.addTask { @Sendable [weak self] in + // We intentionally wait to finish processing one state change before moving on to the next; this means that when we process an ATTACHED state change, we can be sure that the current `hasBeenAttached` annotation correctly reflects the contributor’s previous state changes. for await stateChange in subscription { await self?.didReceiveStateChange(stateChange, forContributor: contributor) } @@ -264,7 +265,7 @@ internal actor DefaultRoomLifecycleManager