stride: Runtime rasterized fonts are completely broken
Release Type: Github latest master branch Version: Current master branch
Related to #1692 and #1700 . This issue represents the possible root cause to these two issues. Platform(s): Windows
Describe the bug Attempting to To Reproduce Steps to reproduce the behavior:
- Same as #1692 . Create a new project with the
Animationtemplate. Wait for segmentation faults. OR - Creating a new project:
1.) Create a new blank project
2.) Add a UI Page
3.) Try to add a
Text block. 4.) Memory error atFontManager.RenderBitmap(). Or any other error related toSharpFont. YMMV.
Workaround Do not use Stride’s default font. Avoid using runtime rasterized fonts. Manually create and assign font assets.
Expected behavior Proper rendering of the fonts.
Screenshots
A possible clue and warning sign is that Stride itself shows that it can’t load fonts. The default font is broken, and it is used by default when adding UI elements, thus possibly triggering a segfault.
Also, as a consequence, button texts are non-existent. No crashes are seen when working with buttons. Crashes can be triggered if editing the button text or text block.
Log and callstacks
There are different crashes caused by this same issue.
Stacktrace 1
> SharpFont.dll!SharpFont.GlyphSlot.RenderGlyph(SharpFont.RenderMode mode) Line 100 C#
Stride.Graphics.dll!Stride.Graphics.Font.FontManager.RenderBitmap(Stride.Graphics.Font.CharacterSpecification character, SharpFont.Face fontFace) Line 159 C#
Stride.Graphics.dll!Stride.Graphics.Font.FontManager.BuildBitmapThread() Line 321 C#
Stride.Core.dll!Stride.Core.Diagnostics.SafeAction.Wrap.AnonymousMethod__0() Line 22 C#
System.Private.CoreLib.dll!System.Threading.Thread.StartHelper.RunWorker() Line 73 C#
System.Private.CoreLib.dll!System.Threading.Thread.StartHelper.Callback(object state) Line 43 C#
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 184 C#
System.Private.CoreLib.dll!System.Threading.Thread.StartHelper.Run() Line 50 C#
System.Private.CoreLib.dll!System.Threading.Thread.StartCallback() Line 106 C#
Editor error 1
System.OverflowException: Arithmetic operation resulted in an overflow.
at Stride.Graphics.Font.FontManager.GenerateCharacterGlyph(CharacterSpecification character, Boolean renderBitmap) in D:\Dev\Stride\sources\engine\Stride.Graphics\Font\FontManager.cs:line 120
at Stride.Graphics.Font.FontManager.GenerateBitmap(CharacterSpecification characterSpecification, Boolean synchronously) in D:\Dev\Stride\sources\engine\Stride.Graphics\Font\FontManager.cs:line 101
at Stride.Graphics.Font.RuntimeRasterizedSpriteFont.GetGlyph(CommandList commandList, Char character, Vector2& fontSize, Boolean uploadGpuResources, Vector2& fixScaling) in D:\Dev\Stride\sources\engine\Stride.Graphics\Font\RuntimeRasterizedSpriteFont.cs:line 111
at Stride.Graphics.SpriteFont.ForGlyph[T](CommandList commandList, StringProxy& text, Vector2& fontSize, GlyphAction`1 action, T& parameters, Int32 forStart, Int32 forEnd, Boolean updateGpuResources, Single startX, Single startY) in D:\Dev\Stride\sources\engine\Stride.Graphics\SpriteFont.cs:line 575
at Stride.Graphics.SpriteFont.ForEachGlyph[T](CommandList commandList, StringProxy& text, Vector2& requestedFontSize, GlyphAction`1 action, T& parameters, TextAlignment scanOrder, Boolean updateGpuResources, Nullable`1 textBoxSize) in D:\Dev\Stride\sources\engine\Stride.Graphics\SpriteFont.cs:line 512
at Stride.Graphics.SpriteFont.MeasureString(StringProxy& text, Vector2& size) in D:\Dev\Stride\sources\engine\Stride.Graphics\SpriteFont.cs:line 452
at Stride.UI.Controls.TextBlock.CalculateTextSize(StringProxy textToMeasure) in D:\Dev\Stride\sources\engine\Stride.UI\Controls\TextBlock.cs:line 261
at Stride.UI.Controls.TextBlock.CalculateTextSize(String textToMeasure) in D:\Dev\Stride\sources\engine\Stride.UI\Controls\TextBlock.cs:line 208
at Stride.UI.Controls.TextBlock.MeasureOverride(Vector3 availableSizeWithoutMargins) in D:\Dev\Stride\sources\engine\Stride.UI\Controls\TextBlock.cs:line 215
at Stride.UI.UIElement.Measure(Vector3 availableSizeWithMargins) in D:\Dev\Stride\sources\engine\Stride.UI\UIElement.cs:line 908
at Stride.UI.Controls.ContentControl.MeasureOverride(Vector3 availableSizeWithoutMargins) in D:\Dev\Stride\sources\engine\Stride.UI\Controls\ContentControl.cs:line 90
at Stride.UI.Controls.Button.MeasureOverride(Vector3 availableSizeWithoutMargins) in D:\Dev\Stride\sources\engine\Stride.UI\Controls\Button.cs:line 183
at Stride.UI.UIElement.Measure(Vector3 availableSizeWithMargins) in D:\Dev\Stride\sources\engine\Stride.UI\UIElement.cs:line 908
at Stride.UI.Panels.StackPanel.MeasureOverride(Vector3 availableSizeWithoutMargins) in D:\Dev\Stride\sources\engine\Stride.UI\Panels\StackPanel.cs:line 217
at Stride.UI.UIElement.Measure(Vector3 availableSizeWithMargins) in D:\Dev\Stride\sources\engine\Stride.UI\UIElement.cs:line 908
at Stride.Rendering.UI.UIRenderFeature.DrawInternal(RenderDrawContext context, RenderView renderView, RenderViewStage renderViewStage, Int32 startIndex, Int32 endIndex) in D:\Dev\Stride\sources\engine\Stride.UI\Rendering\UI\UIRenderFeature.cs:line 234
at Stride.Rendering.UI.UIRenderFeature.Draw(RenderDrawContext context, RenderView renderView, RenderViewStage renderViewStage, Int32 startIndex, Int32 endIndex) in D:\Dev\Stride\sources\engine\Stride.UI\Rendering\UI\UIRenderFeature.cs:line 86
at Stride.Rendering.RenderSystem.Draw(RenderDrawContext renderDrawContext, RenderView renderView, RenderStage renderStage) in D:\Dev\Stride\sources\engine\Stride.Rendering\Rendering\RenderSystem.cs:line 341
at Stride.Rendering.Compositing.ForwardRenderer.DrawView(RenderContext context, RenderDrawContext drawContext, Int32 eyeIndex, Int32 eyeCount) in D:\Dev\Stride\sources\engine\Stride.Engine\Rendering\Compositing\ForwardRenderer.cs:line 555
at Stride.Rendering.Compositing.ForwardRenderer.DrawCore(RenderContext context, RenderDrawContext drawContext) in D:\Dev\Stride\sources\engine\Stride.Engine\Rendering\Compositing\ForwardRenderer.cs:line 750
at Stride.Rendering.Compositing.SceneRendererBase.Draw(RenderDrawContext context) in D:\Dev\Stride\sources\engine\Stride.Rendering\Rendering\Compositing\SceneRendererBase.cs:line 38
at Stride.Rendering.Compositing.EditorTopLevelCompositor.DrawInner(RenderDrawContext context) in D:\Dev\Stride\sources\engine\Stride.Engine\Rendering\Compositing\EditorTopLevelCompositor.cs:line 61
at Stride.Rendering.Compositing.SceneCameraRenderer.DrawCore(RenderContext context, RenderDrawContext drawContext) in D:\Dev\Stride\sources\engine\Stride.Engine\Rendering\Compositing\SceneCameraRenderer.cs:line 70
at Stride.Rendering.Compositing.SceneRendererBase.Draw(RenderDrawContext context) in D:\Dev\Stride\sources\engine\Stride.Rendering\Rendering\Compositing\SceneRendererBase.cs:line 38
at Stride.Rendering.Compositing.GraphicsCompositor.DrawCore(RenderDrawContext context) in D:\Dev\Stride\sources\engine\Stride.Engine\Rendering\Compositing\GraphicsCompositor.cs:line 116
at Stride.Rendering.RendererBase.Draw(RenderDrawContext context) in D:\Dev\Stride\sources\engine\Stride.Rendering\Rendering\RendererBase.cs:line 49
at Stride.Engine.SceneSystem.Draw(GameTime gameTime) in D:\Dev\Stride\sources\engine\Stride.Engine\Engine\SceneSystem.cs:line 232
at Stride.Games.GameSystemCollection.Draw(GameTime gameTime) in D:\Dev\Stride\sources\engine\Stride.Games\GameSystemCollection.cs:line 125
at Stride.Games.GameBase.Draw(GameTime gameTime) in D:\Dev\Stride\sources\engine\Stride.Games\GameBase.cs:line 795
at Stride.Editor.EditorGame.Game.EditorServiceGame.Draw(GameTime gameTime) in D:\Dev\Stride\sources\editor\Stride.Editor\EditorGame\Game\EditorServiceGame.cs:line 214
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 23 (18 by maintainers)
Commits related to this issue
- [Build] Fix native library loading picking up invalid files (fixes #1750) — committed to Basewq/stride by Basewq 8 months ago
- [Build] Fix native library loading picking up invalid files (fixes #1750) — committed to Basewq/stride by Basewq 8 months ago
I think I’ve found the issue. It appears to be a combo of #1428 and #1254
When running in debug mode, the method
ListNativeLibswill end retrieving the full path forfreetype.dllANDfreetype.pdbhttps://github.com/vvvv/stride/blob/b8102af29b18a7fed854dc1b32ddfca362ccaa42/sources/shared/Stride.NuGetResolver/RestoreHelper.cs#L83-L122This line was changed from loading
"freetype.dll"to just"freetype"in #1254 https://github.com/manio143/stride/blob/31a6c999369d084571c276cc049e0fa2e30fac57/sources/engine/Stride.Graphics/Font/FontManager.cs#L82Then this tries to load the
freetypelibrary, but fails the firstNativeLibrary.TryLoadbecause it actually tried to loadfreetype.pdbon the first line https://github.com/vvvv/stride/blob/b8102af29b18a7fed854dc1b32ddfca362ccaa42/sources/core/Stride.Core/Native/NativeLibraryHelper.cs#L39-L53 However it continues to the secondNativeLibrary.TryLoadstatement and succeeds, however most likely it loaded the dll from some other place (where exactly it finds it, I don’t know however I believe it using some other registeredfreetype.dllthat might be registered somewhere, which is NOT compatible with Stride’s one since it is a custom built dll).So the solution is either change
GetLibPathsto check if it’s a pdb file and exclude it from the list, and/or remove thefreetype.pdbfrom being included in the outputs.This is not reproductible under the latest Stride release.
So I did some testing with all of the recent release tags and below are the results. current master - broken https://github.com/stride3d/stride/releases/tag/releases%2F4.1.0.1898 - working https://github.com/stride3d/stride/releases/tag/releases%2F4.1.0.1897 - broken https://github.com/stride3d/stride/releases/tag/releases%2F4.1.0.1838 - working https://github.com/stride3d/stride/releases/tag/releases%2F4.1.0.1822 - working https://github.com/stride3d/stride/releases/tag/releases%2F4.1.0.1805 - fully working with thumbnail as well
So I took the time to go through a bunchl of the releases to see which ones have this issue as it seems to have been on and off since June. The most notable thing in this is 1805 where it seems like runtime rasterized is fully working with zero errors even in the thumbnail.