Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering specific text crashes the application #15587

Open
HermanKirshin opened this issue May 2, 2024 · 9 comments · May be fixed by #15971
Open

Rendering specific text crashes the application #15587

HermanKirshin opened this issue May 2, 2024 · 9 comments · May be fixed by #15971

Comments

@HermanKirshin
Copy link
Contributor

HermanKirshin commented May 2, 2024

Describe the bug

An exception occurs on attempt to render some specific characters in TextBlock (probably arabic symbol ۿ)

To Reproduce

Create text box and set this value to text. Run app and get exception
(By the way I'm using Inter font if it matters)

TextBlock.Text = "%+,0:<?A[^_`{|}~�\u00a2«\u00ac\u00ad\u00ae·\u00b8»\u00bc¿ÀȡȢȴɐʮʰ\u02ef\u0300\u0350\u0360ͰʹͶͺͻ\u0384·Έ\u038bΌ\u038dΎ\u03a2ΣϏϐϷЀ\u0487\u0488ӏӐӶӸӺԀԐԱ\u0557ՙ՚աֈ\u05ba\u05bb\u0591\u05a2\u05a3־\u05bf׀\u05c1׃\u05c5\u05c4א\u05ebװ׳ءػـ\u0656٠٪ٮ۔ە\u06dd\u06deۮ۰ۿܐܭ\u0730\u074bހ\u07b2\u0901ऄअ\u093a\u093c\u094eॐ\u0955क\u093c।०॰\u0981\u0984অ\u098dএ\u0991ও\u09a9প\u09b1ল\u09b3শ\u09ba\u09bcঽ\u09be\u09c5\u09c7\u09c9\u09cbৎ\u09d7\u09d8ড\u09bc\u09deয\u09bc\u09e4০\u09fb\u0a02\u0a03ਅ\u0a0bਏ\u0a11ਓ\u0a29ਪ\u0a31ਲ\u0a34ਵ\u0a37ਸ\u0a3a\u0a3c\u0a3d\u0a3e\u0a43\u0a47\u0a49\u0a4b\u0a4eਖ\u0a3c\u0a5dਫ\u0a3c\u0a5f੦\u0a75\u0a81\u0a84અઌઍ\u0a8eએ\u0a92ઓ\u0aa9પ\u0ab1લ\u0ab4વ\u0aba\u0abc\u0ac6\u0ac7\u0aca\u0acb\u0aceૐ\u0ad1ૠૡ૦૰\u0b01\u0b04ଅ\u0b0dଏ\u0b11ଓ\u0b29ପ\u0b31ଲ\u0b34ଶ\u0b3a\u0b3c\u0b44\u0b47\u0b49\u0b4b\u0b4e\u0b56\u0b58ଡ\u0b3c\u0b5eୟ\u0b62୦ୱ\u0b82\u0b84அ\u0b8bஎ\u0b91ஒ\u0b96ங\u0b9bஜ\u0b9dஞ\u0ba0ண\u0ba5ந\u0babமஶஷ\u0bba\u0bbe\u0bc3\u0bc6\u0bc9\u0bca\u0bce\u0bd7\u0bd8௧\u0bf3\u0c01\u0c04అ\u0c0dఎ\u0c11ఒ\u0c29పఴవ\u0c3a\u0c3e\u0c45\u0c46\u0c49\u0c4a\u0c4e\u0c55\u0c57ౠ\u0c62౦\u0c70\u0c82಄ಅ\u0c8dಎ\u0c91ಒ\u0ca9ಪ\u0cb4ವ\u0cba\u0cbe\u0cc5\u0cc6\u0cc9\u0cca\u0cce\u0cd5\u0cd7ೞ\u0cdfೠ\u0ce2೦\u0cf0\u0d02ഄഅ\u0d0dഎ\u0d11ഒഩപഺ\u0d3e\u0d44\u0d46\u0d49\u0d4aൎ\u0d57\u0d58ൠ\u0d62൦\u0d70\u0d82\u0d84අ\u0d97ක\u0db2ඳ\u0dbcල\u0dbeව\u0dc7\u0dca\u0dcb\u0dcf\u0dd5\u0dd6\u0dd7\u0dd8\u0de0\u0df2෴ก\u0e3b\u0e3f๏๐๚ກ\u0e83ຄ\u0e85ງຉຊ\u0e8bຍຎດຘນຠມ\u0ea4ລ\u0ea6ວຨສຬອ\u0eba\u0ebb\u0ebeເ\u0ec5ໆ\u0ec7\u0ec8\u0ece໐\u0edaໜໞༀ༄\u0f13༺\u0f3e\u0f48ཉཫ\u0f71྅\u0f86ྌ\u0f90\u0f98\u0f99\u0fbd\u0fbe\u0fcd\u0fcf࿐ကဢဣဨဩ\u102b\u102c\u1033\u1036\u103a၀၊ၐၚႠ\u10c6აჹᄀᅚᅟᆣᆨᇺሀሇለቇቈ\u1249ቊ\u124eቐ\u1257ቘ\u1259ቚ\u125eበኇኈ\u1289ኊ\u128eነኯኰ\u12b1ኲ\u12b6ኸ\u12bfዀ\u12c1ዂ\u12c6ወዏዐ\u12d7ዘዯደጏጐ\u1311ጒ\u1316ጘጟጠፇፈ\u135b\u1369\u137dᎠᏵᐁ\u166dᙯᙷᚁ᚛ᚠ᛫\u16eeᛱᜀᜍᜎ\u1715ᜠ᜵ᝀ\u1754ᝠ\u176dᝮ\u1771\u1772\u1774ក។ៗ៘\u17db\u17dd០\u17ea\u180b\u180e᠐\u181aᠠᡸᢀᢪḀẜẠỺἀ\u1f16Ἐ\u1f1eἠ\u1f46Ὀ\u1f4eὐ\u1f58Ὑ\u1f5aὛ\u1f5cὝ\u1f5eὟ\u1f7eᾀ\u1fb5ᾶ\u1fc5ῆ\u1fd4ῖ\u1fdc\u1fdd\u1ff0ῲ\u1ff5ῶ\u1fff\u2044⁅\u2052⁓\u2070\u2072\u2074⁽ⁿ₍\u20a0\u20b2\u20eb\u20d0\u2100\u213bℽ\u214c\u2153ↄ\u2190〈\u232b\u23b4\u23b7\u23cf\u2400\u2427\u2440\u244b\u2460\u24ff\u2500\u2614\u2616\u2618\u2619\u267e\u2680\u268a\u2701\u2705\u2706\u270a\u270c\u2728\u2729\u274c\u274d\u274e\u274f\u2753\u2756\u2757\u2758\u275f\u2761❨\u2776\u2795\u2798\u27b0\u27b1\u27bf\u27d0⟦\u27f0⦃\u2999⧘\u29dc⧼\u29fe\u2b00\u2e80\u2e9a\u2e9b\u2ef4\u2f00\u2fd6\u2ff0\u2ffc\u3004〈\u3012〔\u3020〰〱〽\u303e\u3040ぁ\u3097\u3099゠ァ・ー\u3100ㄅㄭㄱ\u318f\u3190ㆸㇰ\u321d\u3220\u3244\u3251\u327c\u327f\u32cc\u32d0\u32ff\u3300\u3377\u337b\u33de\u33e0\u33ff㐀䶶一龦ꀀ\ua48d\ua490\ua4c7가\ud7a4豈郞侮恵ff\ufb07ﬓ\ufb18י\u05b4\ufb37ט\u05bc\ufb3dמ\u05bc\ufb3fנ\u05bc\ufb42ף\u05bc\ufb45צ\u05bc\ufbb2ﯓ﴾ﵐ\ufd90ﶒ\ufdc8ﷰ\ufdfd\ufe00︐\ufe20\ufe24\ufe62﹣\ufe64\ufe67\ufe69﹪ﹰ\ufe75ﹶ\ufefd\uff04%\uff0b,0:\uff1c?A[\uff3e_\uff40{\uff5c}\uff5e⦅ヲ\uffbfᅡ\uffc8ᅧ\uffd0ᅭ\uffd8ᅳ\uffdd\uffe0\uffe7\uffe8\uffef\ufffc\ufffe";

Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Avalonia.Media.GlyphRun.CreateGlyphRunMetrics()
   at Avalonia.Media.GlyphRun.get_Metrics()
   at Avalonia.Media.GlyphRun.get_BaselineOrigin()
   at Avalonia.Media.GlyphRun.CreateGlyphRunImpl()
   at Avalonia.Media.GlyphRun.get_PlatformImpl()
   at Avalonia.Media.GlyphRun.get_InkBounds()
   at Avalonia.Media.TextFormatting.TextLineImpl.CreateLineMetrics()
   at Avalonia.Media.TextFormatting.TextLineImpl.FinalizeLine()
   at Avalonia.Media.TextFormatting.TextFormatterImpl.FormatLine(ITextSource textSource, Int32 firstTextSourceIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak)
   at Avalonia.Media.TextFormatting.TextLayout.CreateTextLines()
   at Avalonia.Media.TextFormatting.TextLayout..ctor(ITextSource textSource, TextParagraphProperties paragraphProperties, TextTrimming textTrimming, Double maxWidth, Double maxHeight, Int32 maxLines)
   at Avalonia.Controls.TextBlock.CreateTextLayout(String text)
   at Avalonia.Controls.TextBlock.get_TextLayout()
   at Avalonia.Controls.TextBlock.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutHelper.MeasureChild(Layoutable control, Size availableSize, Thickness padding, Thickness borderThickness)
   at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutHelper.MeasureChild(Layoutable control, Size availableSize, Thickness padding)
   at Avalonia.Controls.Decorator.MeasureOverride(Size availableSize)
   at Avalonia.Controls.Primitives.VisualLayerManager.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize)
   at Avalonia.Controls.Window.MeasureOverride(Size availableSize)
   at Avalonia.Controls.WindowBase.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutManager.Measure(Layoutable control)
   at Avalonia.Layout.LayoutManager.ExecuteInitialLayoutPass()
   at Avalonia.Controls.Window.ShowCore(Window owner)
   at Avalonia.Controls.Window.Show()
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.ShowMainWindow()
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action`1 lifetimeBuilder)
   at AvaloniaApplication4.Program.Main(String[] args) in /Users/Herman.Kirshin/Code/AvaloniaApplication4/AvaloniaApplication4/Program.cs:line 48

Expected behavior

No exception occurs

Avalonia version

11.0.10

OS

macOS

Additional context

No response

@Gillibald
Copy link
Contributor

Please properly encode the sample text

@HermanKirshin
Copy link
Contributor Author

\u0025\u002b\u002c\u0030\u003a\u003c\u003f\u0041\u005b\u005e\u005f\u0060\u007b\u007c\u007d\u007e\ufffd\u00a2\u00ab\u00ac\u00ad\u00ae\u00b7\u00b8\u00bb\u00bc\u00bf\u00c0\u0221\u0222\u0234\u0250\u02ae\u02b0\u02ef\u0300\u0350\u0360\u0370\u02b9\u0376\u037a\u037b\u0384\u00b7\u0388\u038b\u038c\u038d\u038e\u03a2\u03a3\u03cf\u03d0\u03f7\u0400\u0487\u0488\u04cf\u04d0\u04f6\u04f8\u04fa\u0500\u0510\u0531\u0557\u0559\u055a\u0561\u0588\u05ba\u05bb\u0591\u05a2\u05a3\u05be\u05bf\u05c0\u05c1\u05c3\u05c5\u05c4\u05d0\u05eb\u05f0\u05f3\u0621\u063b\u0640\u0656\u0660\u066a\u066e\u06d4\u06d5\u06dd\u06de\u06ee\u06f0\u06ff\u0710\u072d\u0730\u074b\u0780\u07b2\u0901\u0904\u0905\u093a\u093c\u094e\u0950\u0955\u0915\u093c\u0964\u0966\u0970\u0981\u0984\u0985\u098d\u098f\u0991\u0993\u09a9\u09aa\u09b1\u09b2\u09b3\u09b6\u09ba\u09bc\u09bd\u09be\u09c5\u09c7\u09c9\u09cb\u09ce\u09d7\u09d8\u09a1\u09bc\u09de\u09af\u09bc\u09e4\u09e6\u09fb\u0a02\u0a03\u0a05\u0a0b\u0a0f\u0a11\u0a13\u0a29\u0a2a\u0a31\u0a32\u0a34\u0a35\u0a37\u0a38\u0a3a\u0a3c\u0a3d\u0a3e\u0a43\u0a47\u0a49\u0a4b\u0a4e\u0a16\u0a3c\u0a5d\u0a2b\u0a3c\u0a5f\u0a66\u0a75\u0a81\u0a84\u0a85\u0a8c\u0a8d\u0a8e\u0a8f\u0a92\u0a93\u0aa9\u0aaa\u0ab1\u0ab2\u0ab4\u0ab5\u0aba\u0abc\u0ac6\u0ac7\u0aca\u0acb\u0ace\u0ad0\u0ad1\u0ae0\u0ae1\u0ae6\u0af0\u0b01\u0b04\u0b05\u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6\u0ec7\u0ec8\u0ece\u0ed0\u0eda\u0edc\u0ede\u0f00\u0f04\u0f13\u0f3a\u0f3e\u0f48\u0f49\u0f6b\u0f71\u0f85\u0f86\u0f8c\u0f90\u0f98\u0f99\u0fbd\u0fbe\u0fcd\u0fcf\u0fd0\u1000\u1022\u1023\u1028\u1029\u102b\u102c\u1033\u1036\u103a\u1040\u104a\u1050\u105a\u10a0\u10c6\u10d0\u10f9\u1100\u115a\u115f\u11a3\u11a8\u11fa\u1200\u1207\u1208\u1247\u1248\u1249\u124a\u124e\u1250\u1257\u1258\u1259\u125a\u125e\u1260\u1287\u1288\u1289\u128a\u128e\u1290\u12af\u12b0\u12b1\u12b2\u12b6\u12b8\u12bf\u12c0\u12c1\u12c2\u12c6\u12c8\u12cf\u12d0\u12d7\u12d8\u12ef\u12f0\u130f\u1310\u1311\u1312\u1316\u1318\u131f\u1320\u1347\u1348\u135b\u1369\u137d\u13a0\u13f5\u1401\u166d\u166f\u1677\u1681\u169b\u16a0\u16eb\u16ee\u16f1\u1700\u170d\u170e\u1715\u1720\u1735\u1740\u1754\u1760\u176d\u176e\u1771\u1772\u1774\u1780\u17d4\u17d7\u17d8\u17db\u17dd\u17e0\u17ea\u180b\u180e\u1810\u181a\u1820\u1878\u1880\u18aa\u1e00\u1e9c\u1ea0\u1efa\u1f00\u1f16\u1f18\u1f1e\u1f20\u1f46\u1f48\u1f4e\u1f50\u1f58\u1f59\u1f5a\u1f5b\u1f5c\u1f5d\u1f5e\u1f5f\u1f7e\u1f80\u1fb5\u1fb6\u1fc5\u1fc6\u1fd4\u1fd6\u1fdc\u1fdd\u1ff0\u1ff2\u1ff5\u1ff6\u1fff\u2044\u2045\u2052\u2053\u2070\u2072\u2074\u207d\u207f\u208d\u20a0\u20b2\u20eb\u20d0\u2100\u213b\u213d\u214c\u2153\u2184\u2190\u3008\u232b\u23b4\u23b7\u23cf\u2400\u2427\u2440\u244b\u2460\u24ff\u2500\u2614\u2616\u2618\u2619\u267e\u2680\u268a\u2701\u2705\u2706\u270a\u270c\u2728\u2729\u274c\u274d\u274e\u274f\u2753\u2756\u2757\u2758\u275f\u2761\u2768\u2776\u2795\u2798\u27b0\u27b1\u27bf\u27d0\u27e6\u27f0\u2983\u2999\u29d8\u29dc\u29fc\u29fe\u2b00\u2e80\u2e9a\u2e9b\u2ef4\u2f00\u2fd6\u2ff0\u2ffc\u3004\u3008\u3012\u3014\u3020\u3030\u3031\u303d\u303e\u3040\u3041\u3097\u3099\u30a0\u30a1\u30fb\u30fc\u3100\u3105\u312d\u3131\u318f\u3190\u31b8\u31f0\u321d\u3220\u3244\u3251\u327c\u327f\u32cc\u32d0\u32ff\u3300\u3377\u337b\u33de\u33e0\u33ff\u3400\u4db6\u4e00\u9fa6\ua000\ua48d\ua490\ua4c7\uac00\ud7a4\u8c48\u90de\u4fae\u6075\ufb00\ufb07\ufb13\ufb18\u05d9\u05b4\ufb37\u05d8\u05bc\ufb3d\u05de\u05bc\ufb3f\u05e0\u05bc\ufb42\u05e3\u05bc\ufb45\u05e6\u05bc\ufbb2\ufbd3\ufd3e\ufd50\ufd90\ufd92\ufdc8\ufdf0\ufdfd\ufe00\ufe10\ufe20\ufe24\ufe62\ufe63\ufe64\ufe67\ufe69\ufe6a\ufe70\ufe75\ufe76\ufefd\uff04\uff05\uff0b\uff0c\uff10\uff1a\uff1c\uff1f\uff21\uff3b\uff3e\uff3f\uff40\uff5b\uff5c\uff5d\uff5e\uff5f\uff66\uffbf\uffc2\uffc8\uffca\uffd0\uffd2\uffd8\uffda\uffdd\uffe0\uffe7\uffe8\uffef\ufffc\ufffe

@timunie
Copy link
Contributor

timunie commented May 2, 2024

could you also test 11.1.0-beta2?

@HermanKirshin
Copy link
Contributor Author

in 11.1.0-beta2 error is the same

@Gillibald
Copy link
Contributor

Please attach a sample project here I still can't use your provided sample

@HermanKirshin
Copy link
Contributor Author

Sample

HermanKirshin pushed a commit to JetBrains/Avalonia that referenced this issue May 16, 2024
@mgkcorty
Copy link

mgkcorty commented Jun 10, 2024

Same issue! Reproduced on Windows and Mac OS X.
Screenshot 2024-06-10 at 11 14 05 AM
@HermanKirshin How do you resolve this?

@HermanKirshin
Copy link
Contributor Author

HermanKirshin commented Jun 10, 2024

@mgkcorty I added workaround to GlyphRun inside Avalonia sources
image
It works, but I doubt that it is a good fix for upstream (I'm not yet immersed enough into text processing part to make a fix of which I would be sure), so it was not transformed to PR.

Without modifying the sources I'm afraid the only workaround is to filter string values before binding them to the controls.

@mgkcorty mgkcorty linked a pull request Jun 10, 2024 that will close this issue
3 tasks
@mgkcorty
Copy link

@HermanKirshin Looks like it's acceptable solution, because _glyphInfos can be empty in our case. Thanks for investigation, PR #15971.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants