Open xEricL opened 2 weeks ago
@xEricL, I can't reproduce
Here is the code I'm using
package main
import (
"bytes"
"embed"
"image"
"image/png"
"github.com/AllenDang/giu"
)
//go:embed assets/*
var assets embed.FS
var (
logo *image.RGBA
window *giu.MasterWindow
)
func main() {
window = giu.NewMasterWindow(
"Updater",
377, 144,
giu.MasterWindowFlagsFrameless|giu.MasterWindowFlagsNotResizable|giu.MasterWindowFlagsTransparent,
)
logo, _ = loadImage(assets, "assets/logo.png")
window.Run(defaultUI)
}
func defaultUI() {
giu.SingleWindow().Layout(
giu.Align(giu.AlignCenter).To(
giu.Dummy(0, scaleDivider(6)),
giu.ImageWithRgba(logo).Size(80, 80),
giu.Dummy(0, scaleDivider(6)),
giu.ProgressBar(ReadProgress()).Size(scaleValueX(377)*0.75, scaleValueY(5)),
),
)
}
func ReadProgress() float32 {
return 0.5
}
func scaleDivider(value float32) float32 {
_, yScale := giu.Context.Backend().ContentScale()
if yScale > 1.0 {
value *= 2
}
return value * yScale
}
func scaleValueY(value int) float32 {
_, yScale := giu.Context.Backend().ContentScale()
return float32(value) * yScale
}
func scaleValueX(value int) float32 {
xScale, _ := giu.Context.Backend().ContentScale()
return float32(value) * xScale
}
func loadImage(assets embed.FS, path string) (*image.RGBA, error) {
data, err := assets.ReadFile(path)
if err != nil {
return nil, err
}
img, err := png.Decode(bytes.NewReader(data))
if err != nil {
return nil, err
}
return giu.ImageToRgba(img), nil
}
It works fine (assets/logo.png for me is examples/loadimage/gopher.png)
I've a suggestion for your project: make sure your style.go
does not use AllenDang/imgui-go - you need AllenDang/cimgui-go
I've a suggestion for your project: make sure your
style.go
does not use AllenDang/imgui-go - you need AllenDang/cimgui-go
@gucio321 I've made sure to update my style.go. I've pushed the updated code to a new branch https://github.com/alpine-client/pinnacle/tree/giu-v0.8
I didn't think styling was the issue because it still happens even if I removed SetupStyle
and PopStyle
from the defaultUI() function.
After further testing, I've discovered 2 cases where the SIGSEV does not happen (which should narrow down the issue):
giu.ImageWithRgba(logo)
from defaultUI()
. Specifically, this line: https://github.com/alpine-client/pinnacle/blob/92462557244d9d37c35cae535529d894a9e5b21d/ui/ui.go#L88giu.ImageWithRgba(logo)
line and run the code again (skips most of the progress bar)Let me further explain our program. It basically downloads and unzips Java 17, downloads a launcher.jar
from our website, and then uses the Java binary to run launcher.jar
. This only needs to happen once, so if the program detects that the Java runtime package and launcher.jar already exist on the system, it doesn't do it again. This means the progress bar goes much faster after 1 successful run. As a result, if you get the program to run successfully, you need to delete ~/.alpineclient/
before running it again or else SIGSEV won't happen again (I know, it's very strange).
Since you're unable to recreate it, please clone this branch, run make run
, and the SIGSEV should happen. Once again, the program only interacts with ~/.alpineclient/
, so remember to delete that after a successful run (and at the end when you're finished testing). I've also commented out the code that runs launcher.jar
(so no other code will be executed on your system).
Please let me know if you're still unable to recreate it under these conditions. The issue is most likely related to giu.ImageWithRgba
(case 1). Although I don't know why the SIGSEV doesn't happen after 1 successful run (case 2).
Even if I comment out the progress bar and only load the image by itself, the SIGSEV occurs. It is almost certainly caused by giu.ImageWithRgba
.
Replacing giu.ImageWithRgba
with giu.ImageWithURL
fixes the issue. Not an ideal solution but will have to do in the meantime. This is probably a lower-level issue with cimgui-go.
Image with url is almost the same as image with rgba iirc So this night be a giu issue, let me investigate it
@xEricL I'm sorry but I'm still unable to reproduce:
https://github.com/user-attachments/assets/c7559080-d283-4381-9916-cd4ebad18022
That is very interesting. I just tested it in a Debian 11 Virtual Machine and it compiled and ran no problem. Perhaps it's just an issue with Fedora 40 or maybe even just a problem with my system.
Thank you for the video and for taking the time to look into this.
@xEricL I'm on fedora 39. I can check on f40 laptop later.
You use wayland or xorg? And what gpu?
You use wayland or xorg? And what gpu?
I'm on xorg. GPU is NVIDIA 2060S.
@xEricL I managed to reproduce on fedora 40 laptop with nvidia gpu. I have no idea is it hardware or os thing yet. Will try to debug this.
fedora 40 PC with no gpu - still works for me. This must be something about gpu (but why?) Generally ImageWithRGBa has something to do with texture loading and this is deffinitly gpu thing.
It likely has something to do with NVIDIA drivers for Fedora 40.
Very weird that giu.ImageWithURL
and giu.ImageWithFile
work just fine. I decided to just go with giu.ImageWithFile
. Perhaps it will resolve on it's own with a NVIDIA driver update in the future. Thank you again for taking the time to look into this for me.
What happend?
This code worked in v0.7. Updating to v0.8.1 causes a segment violation at runtime.
Code example
```golang //go:embed assets/* var assets embed.FS var ( logo *image.RGBA window *giu.MasterWindow ) func main(){ window = giu.NewMasterWindow( "Updater", 377, 144, giu.MasterWindowFlagsFrameless|giu.MasterWindowFlagsNotResizable|giu.MasterWindowFlagsTransparent, ) logo, _ = loadImage(assets, "assets/logo.png") window.Run(defaultUI) } func defaultUI() { giu.SingleWindow().Layout( giu.Align(giu.AlignCenter).To( giu.Dummy(0, scaleDivider(6)), giu.ImageWithRgba(logo).Size(80, 80), giu.Dummy(0, scaleDivider(6)), giu.ProgressBar(ReadProgress()).Size(scaleValueX(377)*0.75, scaleValueY(5)), ), ) } func scaleDivider(value float32) float32 { _, yScale := giu.Context.Backend().ContentScale() if yScale > 1.0 { value *= 2 } return value * yScale } func scaleValueY(value int) float32 { _, yScale := giu.Context.Backend().ContentScale() return float32(value) * yScale } func scaleValueX(value int) float32 { xScale, _ := giu.Context.Backend().ContentScale() return float32(value) * xScale } func loadImage(assets embed.FS, path string) (*image.RGBA, error) { data, err := assets.ReadFile(path) if err != nil { return nil, err } img, err := png.Decode(bytes.NewReader(data)) if err != nil { return nil, err } return giu.ImageToRgba(img), nil } ```main.go
You can also find the actual code I'm using this for here: https://github.com/alpine-client/pinnacle/blob/084fde184a816b2241c36bd4f37a9fced3f21dbf/ui/ui.go#L83
To Reproduce
Version
(latest)
OS
Fedora 40