From 25dc96040cc6f4d7ec124c1bdbb550d5481989e0 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Mon, 8 Jul 2024 09:44:15 +0100 Subject: [PATCH] Potential fix for a crash when 2 present room events are sent in quick succession. (#3001) --- .../Sources/FlowCoordinators/RoomFlowCoordinator.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift index 50a7bb880..47b9bdb7a 100644 --- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift @@ -214,6 +214,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { fatalError("Trying to create different room proxies for the same flow coordinator") } + MXLog.warning("Found an existing proxy, returning.") return } @@ -221,9 +222,12 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { fatalError("Requesting room details for an unjoined room") } - self.roomProxy = roomProxy - await roomProxy.subscribeForUpdates() + + // Make sure not to set this until after the subscription has succeeded, otherwise the + // early return above could result in trying to access the room's timeline provider + // before it has been set which triggers a fatal error. + self.roomProxy = roomProxy } // swiftlint:disable:next function_body_length