Skip to content

Fix crash: disable in-chat SwiftUI translation service (fatal trap in Translation framework internals)#2219

Open
ankuper wants to merge 1 commit into
TelegramMessenger:masterfrom
ankuper:fix/translation-service-swiftui-trap
Open

Fix crash: disable in-chat SwiftUI translation service (fatal trap in Translation framework internals)#2219
ankuper wants to merge 1 commit into
TelegramMessenger:masterfrom
ankuper:fix/translation-service-swiftui-trap

Conversation

@ankuper

@ankuper ankuper commented Jul 2, 2026

Copy link
Copy Markdown

Why

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 fix available on our side is not calling into it.

Fix

Disable instantiation of the local/on-device translation service. This 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. 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 + .translationTask interop issue is understood or fixed by an OS update.

Testing

Verified against the crash report that triggered this (SIGABRT, trap inside UIHostingController/SwiftUI internals immediately following ExperimentalInternalTranslationServiceImpl.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).

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant