Description
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 FontManager.RenderBitmap() access violation exception #1692 . Create a new project with the
Animation
template. Wait for segmentation faults.
OR - Creating a new project:
1.) Create a new blank project
2.) Add a UI Page
3.) Try to add aText 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