TGViewer
Telegram github commits and releases Telegram github commits and releases @tgappsupdates · 4.54K subscribers
Post #20618 110
UnigramDev/Unigram/theme-current-share-target • 7a4368b • 1 files, +11/-2
Register the theme before reading its settings

Theme.Current is thread-static and assigned in exactly one place, and that
assignment sat behind a call that can fail:

try
{
_isolatedStore = ApplicationData.Current.LocalSettings.CreateContainer(...);
Current ??= this;
...
}
catch { }

When CreateContainer throws, the catch is silent and the theme never registers
itself. Every later Theme.Current dereference - and they are unguarded across
the message tree, FormattedTextBlock, MessageBubblePanel, ChatBackgroundControl
- is then a NullReferenceException on that view thread.

Reported by crash telemetry on 12.9.1, through OnShareTargetActivated:
SharePage's constructor calls ChatBackgroundControl.Update, which reads
Theme.Current.ChatBackground and dies. The share target view is driven before
it is initialized - the same race as #3320, which moved this crash one frame
later rather than removing it - and ApplicationData is evidently not always
reachable that early.

That the constructor ran at all is not in doubt: SharePage.xaml resolves
StaticResource EmptyHyperlinkButtonStyle from CommonStyles.xaml, a merged
dictionary of Application.Resources that follows <common:Theme /> in the merge
list, so InitializeComponent could not have returned unless the resources of
this view - the theme among them - had been inflated.

Assign Current before the try. It depends on nothing inside it, and losing a
persisted preference should not cost the view its theme. The catch now logs,
since the whole diagnosis rests on inferring which call threw, and an empty
catch is what made that necessary.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

#unigram
More from @tgappsupdates
  1. Oct 13, 2026TelegramMessenger/tgcalls/dev/android • 245efc4 • 1 files, +29/-111 Revert "Update Instanc…
  2. Oct 13, 2026DrKLO/Telegram/master • 474c462 • 3 files, +8/-0 update submodules DrKLO/Telegram/master •…
  3. Oct 13, 2026morethanwords/tweb/master • e43493d • 47 files, +2788/-39 Calls: denoise the microphone wi…
  4. Oct 13, 2026DrKLO/Telegram/master • 368b6b7 • 76 files, +4839/-2232 update to 13.0.1 (7166) DrKLO/Tele…
  5. Oct 13, 2026DrKLO/Telegram/master • 5e56d34 • 300 files, +66212/-64519 update to 13.0.0 (7158) #androi…
  6. Oct 13, 2026telegramdesktop/tdesktop/dev • 1ac3eeb • 3 files, +36/-1 Keep channel direct messages open…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →