You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fonts Loaded via the Font(byte[] bytes) constructor disappear after a certain time/memory usage. Take the following example
usingSFML.Audio;usingSFML.Graphics;usingSFML.System;usingSFML.Window;usingSystem;usingSystem.Collections.Generic;publicclassProgram{publicstaticvoidMain(string[]args){RenderWindowwindow=newRenderWindow(newVideoMode(800,600),"SFML.net");window.Closed+=(sender,e)=>window.Close();List<CircleShape>shapes=newList<CircleShape>();// Replace with one of your fonts if you don't like me embedding oneTextshapeCount=newText("Shapes: 0",newFont(File.ReadAllBytes("path/to/your/font")),18){Style=Text.Styles.Bold,FillColor=Color.Green,OutlineThickness=1,OutlineColor=Color.Black};while(window.IsOpen){window.DispatchEvents();window.Clear(Color.Black);foreach(CircleShapeshapeinshapes){window.Draw(shape);}shapeCount.DisplayedString=$"Time: {DateTime.Now}";window.Draw(shapeCount);shapes.Add(newCircleShape(50){Position=newVector2f(Random.Shared.Next(0,800),Random.Shared.Next(0,600)),FillColor=newColor((byte)Random.Shared.Next(0,255),(byte)Random.Shared.Next(0,255),(byte)Random.Shared.Next(0,255))});shapes.Add(newCircleShape(50){Position=newVector2f(Random.Shared.Next(0,800),Random.Shared.Next(0,600)),FillColor=newColor((byte)Random.Shared.Next(0,255),(byte)Random.Shared.Next(0,255),(byte)Random.Shared.Next(0,255))});window.Display();}}}
On my machine, the font disappears when the program reaches around 207MB of memory usage (according to Visual Studio's debugger)
Streams are unpredictable. In another project i have, loading the same font used in this example will result in a System.EngineExecutionException if i load it from the assembly resource manifest but works fine if i load it using the file path
The text was updated successfully, but these errors were encountered:
The font doesn't load the whole font data into memory, but goes back and tries to reload certain glyphs at times, but we're pinning the memory and freeing it after, which eventually causes issues.
Later during clean up the same bug was reintroduced with similar code (pin + create from memory), later changed a bit to fixed keyword but the problem remains: 1dfc5db
Music has the same problem, and it was never reported/fixed.
In the past, a workaround (before byte constructor was fixed) was to use a Stream constructor yourself. But now I think this is broken too, due to StreamAdaptor that is Disposed after creating the Font/Music which keep pointer from it (same style issue as pin + construct + use pointer from C++ after it's unpinned in C#).
Fonts Loaded via the
Font(byte[] bytes)
constructor disappear after a certain time/memory usage. Take the following exampleOn my machine, the font disappears when the program reaches around 207MB of memory usage (according to Visual Studio's debugger)
Streams are unpredictable. In another project i have, loading the same font used in this example will result in a
System.EngineExecutionException
if i load it from the assembly resource manifest but works fine if i load it using the file pathThe text was updated successfully, but these errors were encountered: