Fix crash when rendering the wallpaper preview bubbles - #3327
Conversation
The plain-run fast path wrote whatever font size had changed, including 0, and XAML rejects a FontSize of 0 with E_INVALIDARG. GetOrCreateRun already treats non-positive as "inherit" and clears the property instead; the fast path now does the same. MessageBubble.Mockup reaches this: it calls SetText without a font size, so the default of 0 replaces the size the bubble was previously rendered with, and the transition is exactly what triggers the write. Reported by crash telemetry on 12.9.0.0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
I don't think the fix is correct here. I'd rather keep the code as before, but use |
Per review: _fontSize is the raw value, fontSize is what AutoFontSize resolved it to, and the slow path already passes the resolved one to GetOrCreateRun. The fast path writing the raw value is the actual defect, so write the resolved one instead of clearing the property — clearing would inherit the parent's size rather than applying the theme size. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
You're right, and my version would have been wrong in a way the crash wouldn't have shown.
_fontSize = fontSize;
...
if (AutoFontSize && fontSize == 0)
{
fontSize = Theme.Current.MessageFontSize;
}The slow path already passes the resolved Pushed as a follow-up commit rather than a force-push, so the original is still visible. One thing worth recording: a further group has the same anchor but comes through |
* Fix crash when rendering the wallpaper preview bubbles The plain-run fast path wrote whatever font size had changed, including 0, and XAML rejects a FontSize of 0 with E_INVALIDARG. GetOrCreateRun already treats non-positive as "inherit" and clears the property instead; the fast path now does the same. MessageBubble.Mockup reaches this: it calls SetText without a font size, so the default of 0 replaces the size the bubble was previously rendered with, and the transition is exactly what triggers the write. Reported by crash telemetry on 12.9.0.0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Use the computed font size in the fast path Per review: _fontSize is the raw value, fontSize is what AutoFontSize resolved it to, and the slow path already passes the resolved one to GetOrCreateRun. The fast path writing the raw value is the actual defect, so write the resolved one instead of clearing the property — clearing would inherit the parent's size rather than applying the theme size. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Crash
Reported by crash telemetry on 12.9.0.0, as three groups sharing one anchor.
Reached two ways — from the wallpaper picker:
and from an ordinary message in the chat:
Cause
SetTextkeeps the raw argument in_fontSize, then resolves it:The slow path passes the resolved
fontSizetoGetOrCreateRun. The plain-run fast pathinstead reads
_fontSizeback:Every
SetTextoverload declaresdouble fontSize = 0, and callers that don't specify a sizerely on
AutoFontSizeto resolve it. The fast path bypasses that resolution and writes theraw
0, which XAML rejects withE_INVALIDARG. The guard is on change, so it is thetransition from a real size to
0that performs the invalid write.Fix
Write the resolved
fontSize, matching what the slow path already passes toGetOrCreateRun.The first commit here guarded the value and cleared the property instead; that stops the crash
but inherits the parent's size rather than applying the theme size, so it is replaced by the
one-word fix in the follow-up commit.
Verification
Not built or run — a UWP/.NET Native build is not available in the environment this was
prepared in. The edited file was checked with Roslyn (
CSharpSyntaxTree.ParseText) andparses with no syntax errors; that confirms syntax only, not type checking.
🤖 Generated with Claude Code