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

Stride TextBlock newline infinite loop and memory leak #2514

Open
roku674 opened this issue Nov 9, 2024 · 3 comments
Open

Stride TextBlock newline infinite loop and memory leak #2514

roku674 opened this issue Nov 9, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@roku674
Copy link

roku674 commented Nov 9, 2024

There's an infinite loop at TextBlock::UpdateWrappedText ( https://github.com/stride3d/stride/blame/master/sources/engine/Stride.UI/Controls/TextBlock.cs ) when using The text Combat that was most likely placed vertically. These are screenshots from debugging:

As far as I noticed, I think there's not enough space calculated for the first row, plus and the m character keeps being added and deleted because somehow indices are being set to 0 ad infinitum (or well, until the game crashes because of an out of memory error).

Image

@roku674 roku674 added the bug Something isn't working label Nov 9, 2024
@roku674 roku674 changed the title [URGENT] fix needed: Stride TextBlock newline infinite loop and memory leak Stride TextBlock newline infinite loop and memory leak Nov 9, 2024
@IXLLEGACYIXL
Copy link
Collaborator

IXLLEGACYIXL commented Nov 9, 2024

can you make a repro to try it out

@NicusorN5
Copy link
Contributor

NicusorN5 commented Nov 9, 2024

Image

Image
(Second pic taken while writing this post, proving memory is being continously allocated)

I cannot save the project as is, since Stride gets frozen and as you can see in the screenshot, memory keeps increasing. I was not able to attach a debugger since VS2022 would freeze up too.

Here are the steps to reproduce:

  1. Create a new Stride project(either master or 2232)
  2. Create a PageUI asset
  3. Open the newly created asset
  4. Add a Button, scale it to be about 10 units of width
  5. Enable "Wrap Text"
  6. Stride begins to slowly respond, then freeze.
  7. Free memory will run out, so a exception will be thrown (see next post)

In case Stride doesn't freeze, in the original project where I have found this issue, the game was freezing, but not Stride. The reverse was also happening.

@NicusorN5
Copy link
Contributor

I just obtained a stacktrace

System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
   at System.Text.StringBuilder.ExpandByABlock(Int32 minBlockCharCount)
   at System.Text.StringBuilder.AppendCore(StringBuilder value, Int32 startIndex, Int32 count)
   at Stride.UI.Controls.TextBlock.UpdateWrappedText(Vector3 availableSpace) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.UI\Controls\TextBlock.cs:line 334
   at Stride.UI.Controls.TextBlock.MeasureOverride(Vector3 availableSizeWithoutMargins) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.UI\Controls\TextBlock.cs:line 215
   at Stride.UI.UIElement.Measure(Vector3 availableSizeWithMargins) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.UI\UIElement.cs:line 910
   at Stride.UI.Controls.ContentControl.MeasureOverride(Vector3 availableSizeWithoutMargins) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.UI\Controls\ContentControl.cs:line 96
   at Stride.UI.UIElement.Measure(Vector3 availableSizeWithMargins) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.UI\UIElement.cs:line 910
   at Stride.UI.Panels.Grid.MeasureOverride(Vector3 availableSizeWithoutMargins) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.UI\Panels\Grid.cs:line 300
   at Stride.UI.UIElement.Measure(Vector3 availableSizeWithMargins) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.UI\UIElement.cs:line 910
   at Stride.Rendering.UI.UIRenderFeature.DrawInternal(RenderDrawContext context, RenderView renderView, RenderViewStage renderViewStage, Int32 startIndex, Int32 endIndex) in C:\BuildAgent\work\b5f46e3c4829a09e\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 C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.UI\Rendering\UI\UIRenderFeature.cs:line 86
   at Stride.Rendering.RenderSystem.Draw(RenderDrawContext renderDrawContext, RenderView renderView, RenderStage renderStage) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\RenderSystem.cs:line 378
   at Stride.Rendering.Compositing.ForwardRenderer.DrawView(RenderContext context, RenderDrawContext drawContext, Int32 eyeIndex, Int32 eyeCount) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Rendering\Compositing\ForwardRenderer.cs:line 561
   at Stride.Rendering.Compositing.ForwardRenderer.DrawCore(RenderContext context, RenderDrawContext drawContext) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Rendering\Compositing\ForwardRenderer.cs:line 754
   at Stride.Rendering.Compositing.SceneCameraRenderer.DrawInner(RenderDrawContext renderContext) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Rendering\Compositing\SceneCameraRenderer.cs:line 108
   at Stride.Rendering.Compositing.EditorTopLevelCompositor.DrawInner(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Rendering\Compositing\EditorTopLevelCompositor.cs:line 61
   at Stride.Rendering.Compositing.SceneCameraRenderer.DrawCore(RenderContext context, RenderDrawContext drawContext) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Rendering\Compositing\SceneCameraRenderer.cs:line 72
   at Stride.Rendering.Compositing.GraphicsCompositor.DrawCore(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Rendering\Compositing\GraphicsCompositor.cs:line 148
   at Stride.Rendering.RendererBase.Draw(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\RendererBase.cs:line 51
   at Stride.Engine.SceneSystem.Draw(GameTime gameTime) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Engine\SceneSystem.cs:line 234
   at Stride.Games.GameSystemCollection.Draw(GameTime gameTime)
   at Stride.Games.GameBase.Draw(GameTime gameTime)
   at Stride.Editor.EditorGame.Game.EditorServiceGame.Draw(GameTime gameTime) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\editor\Stride.Editor\EditorGame\Game\EditorServiceGame.cs:line 214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants