Fix crash: disable in-chat SwiftUI translation service (fatal trap in Translation framework internals)#2219
Open
ankuper wants to merge 1 commit into
Conversation
…I trap) 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ExperimentalInternalTranslationServiceImpl.initconstructs aUIHostingController(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 fix available on our side is not calling into it.
Fix
Disable instantiation of the local/on-device translation service. This is safe:
TelegramCore'stranslate()already falls back to server-side translation wheneverengineExperimentalInternalTranslationServiceisnil(Translate.swift:228), which is now unconditionally the case. In-chat message translation keeps working through the existing server-side path; only the on-device fast-path (which currently cannot be used without crashing) is disabled.Left the original code commented in place with an explanation, to make it easy to re-enable once the underlying SwiftUI +
.translationTaskinterop issue is understood or fixed by an OS update.Testing
Verified against the crash report that triggered this (
SIGABRT, trap insideUIHostingController/SwiftUI internals immediately followingExperimentalInternalTranslationServiceImpl.init, on the first chat opened after launch). Built and ran on-device (iPhone, iOS 26.5): chats now open normally, and message translation via the server-side path still works.Possibly related to #1739 (reported crash opening any chat after updating to iOS 18.4 — this fix is gated behind
#available(iOS 18.0, *), so the onset lining up with an iOS 18+ update is consistent, though I have not been able to confirm against their crash log).