-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
[bug] crashes when changing texture on a canvas (DeleteTexture / segmentation violation) #879
Comments
I'm sorry, I seem to have fixed it. Just noticed the new examples (asyncimage.go specifically) that use |
@ioxenus if you use |
Yeah, I use the master branch, thanks! After fixing my own custom widget, I noticed that it still crashes. Turned out I was still using the before: var img_icon image.Image
// load image from file (skipping error handling just for the sake of readability)
f, _ := embed_fs.Open("icon.png")
defer f.Close()
img_icon, _, _ := image.Decode(f)
// somewhere in window layout (added some context)
cell := g.Style().SetStyle(g.StyleVarItemSpacing, 4, 4).To(
g.ImageWithRgba(img_icon).Size(20, 20), // was working in giu v0.7
)
table_row := g.TreeTableRow("foobar", cell)
table := g.TreeTable().Rows(...) // etc The example above crashes after a while when the TreeTable gets updated (some rows are added/removed). The stacktrace was the same as above - something about releasing/deleting the texture. after: var img_icon *image.RGBA
var tex_icon = &g.ReflectiveBoundTexture{}
// load image from file
f, _ := embed_fs.Open("icon.png")
defer f.Close()
img, _, _ := image.Decode(f)
img_icon = g.ImageToRgba(img)
// initialize texture
tex_icon.SetSurfaceFromRGBA(img_icon, false)
// somewhere in window layout (skipped context)
tex_icon.ToImageWidget().Size(20, 20) The code above seems to work fine with the current master branch of giu (f64eda1) & cimgui-go (1a15ba4). I have no idea if this issue should stay opened since I found the solution, but it took me some struggling to pinpoint the issue, and, I guess, it may break compatibility after upgrading from giu v0.7 to a newer version of giu/cimgui-go. I'm also pretty new with Go, so it could be that I was doing (and maybe still doing) something wrong. If that's the case - would really appreciate the feedback! |
@ioxenus we'll take a look at this since ImageWithRgba was thought to be (at last) fixed. Aside from that, a quick advice: you do not need to do the
img, _, _ := image.Decode(f)
img_icon = g.ImageToRgba(img)
// initialize texture
tex_icon.SetSurfaceFromRGBA(img_icon, false) to err = tex_icon.SetSurfaceFromFsFile(f, false)
if err != nil {
return fmt.Errorf("error while Setting surface from File: %w", err)
} You can take a look at SurfaceLoaders for more advanced cases that may be relevant: |
GC crashes should be fixed on mater. |
What happend?
This is possibly related to #854 and #819, but the issue still persists for me even with the latest commits:
I made a custom widget that displays a map with a bunch of countries. When I click some country, it gets highlighted and it shows in the UI. I made this using an image mask that has the countries colored with different colors, and when I click on the widget - it gets the pixel color of the clicked country at the (X, Y) and then generates a new image with the highlighted area.
After changing the displayed image a couple of times, the app crashes:
Log & stacktrace
I tried to debug/refactor it with no success; didn't have this issue on giu v0.7.0.
Code example
main.go
To Reproduce
Put these images in the "images" directory (relative to
main.go
):map_areas.png
: https://github.com/user-attachments/assets/a5c3b998-aaff-4257-9fcc-ca59b8517b26map.png
: https://github.com/user-attachments/assets/dd4aacb1-785c-416c-bbcd-18a8f155997cmap_highlighted.png
: https://github.com/user-attachments/assets/e8b974fe-2789-446d-983d-dc23e585ff57palette.png
https://github.com/user-attachments/assets/653203e3-d09a-4d47-817b-bd7a9a22e297Run the
main.go
and try clicking on a several countries.Version
master
OS
darwin / arm64 (macOS 14.6.1)
The text was updated successfully, but these errors were encountered: