From 1e3eb721aafe56df0da6d7ae6c2b573e38733d5f Mon Sep 17 00:00:00 2001 From: ankuper Date: Thu, 2 Jul 2026 14:20:04 -0400 Subject: [PATCH] fix(chat): disable ExperimentalInternalTranslationServiceImpl (SwiftUI trap) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ExperimentalInternalTranslationServiceImpl.init constructs a UIHostingController(rootView: TranslationViewImpl(...)) that fatal-traps inside SwiftUI/Translation-framework internals on device (SIGABRT, no application-code frames at the trap site — confirmed on iOS 26.5, reproducible on the first chat opened per app session, matching the report of the app crashing quickly when viewing chats). Confirmed against upstream: teleproto3-support's merge-base with TelegramMessenger/Telegram-iOS master IS upstream's current tip, so this is not something already fixed there — it needs a local mitigation. A trap inside Apple's own framework code cannot be guarded or caught from Swift, so the only available fix is not calling into it. Disabling this local/on-device translation path is safe: TelegramCore's translate() already falls back to server-side translation whenever engineExperimentalInternalTranslationService is nil (Translate.swift:228), which is now unconditionally the case. --- .../Chat/ChatControllerLoadDisplayNode.swift | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift index 9934503998..d4bcf58e19 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift @@ -683,12 +683,22 @@ extension ChatControllerImpl { } } - if #available(iOS 18.0, *) { - if engineExperimentalInternalTranslationService == nil, let hostView = self.context.sharedContext.mainWindow?.hostView { - let translationService = ExperimentalInternalTranslationServiceImpl(view: hostView.containerView) - engineExperimentalInternalTranslationService = translationService - } - } + // Disabled: ExperimentalInternalTranslationServiceImpl.init constructs a + // UIHostingController(rootView: TranslationViewImpl(...)) that fatal-traps + // inside SwiftUI/Translation-framework internals on device (SIGABRT, no + // application-code frames at the trap site — confirmed on iOS 26.5, + // reproducible on the first chat opened per app session). A trap inside + // Apple's own framework code cannot be guarded or caught from Swift, so + // the only available mitigation is not calling into it. Re-enable once + // the underlying SwiftUI + .translationTask interop bug is understood + // or fixed by an OS update. + // + // if #available(iOS 18.0, *) { + // if engineExperimentalInternalTranslationService == nil, let hostView = self.context.sharedContext.mainWindow?.hostView { + // let translationService = ExperimentalInternalTranslationServiceImpl(view: hostView.containerView) + // engineExperimentalInternalTranslationService = translationService + // } + // } self.displayNode = ChatControllerNode(context: self.context, chatLocation: self.chatLocation, chatLocationContextHolder: self.chatLocationContextHolder, subject: self.subject, controllerInteraction: self.controllerInteraction!, chatPresentationInterfaceState: self.presentationInterfaceState, automaticMediaDownloadSettings: self.automaticMediaDownloadSettings, navigationBar: self.navigationBar, statusBar: self.statusBar, backgroundNode: self.chatBackgroundNode, controller: self)