-
-
Notifications
You must be signed in to change notification settings - Fork 115
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] cairo-rs context.paint() or fill() not working #661
Comments
That sounds like something to report to https://gitlab.freedesktop.org/cairo/ |
I tried to run c code on alpine linux, it works fine, the backgroud shows correctly. So I think it may be a bug of cairo-rs, I'm not sure, here is my c code: #include <cairo.h>
int main(void)
{
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 390, 60);
cr = cairo_create(surface);
cairo_set_source_rgb(cr, 0.0, 1.0, 1.0);
cairo_paint(cr);
cairo_surface_write_to_png(surface, "image.png");
return 0;
}
// gcc t.c -o example `pkg-config --cflags --libs cairo` |
You Rust code uses 100x100
Your Rust code uses If you change them to the same they still behave differently? Are both the C and Rust version linked to the same version of cairo (check with The Rust code is literally just calling those C functions :) |
after changed the args they still behave differently, the backgroud of the image that generated on alpine linux is transparent, here is the images(first image is fully transparent): "The Rust code is literally just calling those C functions", I know this, But I just can't figure out why 😂 thanks for you time btw, I'll do some more research. |
My best guess would be that it's some miscompilation of cairo or so on alpine, or because of alpine using musl |
For the sake of whoever comes across this and wants to find the corresponding cairo issue: https://gitlab.freedesktop.org/cairo/cairo/-/issues/564 |
I finally found out that it should be a problem with rust compilation. It finally works fine after I add an ENV RUSTFLAGS=-Ctarget-feature=-crt-static before cargo build, which means compiling rust code on 'dynamic link' mode(default is static-link, but it's meaningless because I have already used Cairo dynamic link). there should be some bug or strange behavior in rust compilation, I guess. |
There's various strangenesses with musl that require such things, yes. See for example rust-lang/rust#82193 , #387 (comment), rust-lang/compiler-team#422 , gtk-rs/gtk3-rs#351 (comment) and many others |
Bug description
context.paint() or fill() not work on alpine linux, the backgroud of the output png is transparent.
but it works fine on macOS or debian.
How to reproduce
download my example code zip, unzip it, and run
cd cairo-issue
:cairo-issue.zip
in docker shell:
check the output.png in code folder, the background of the output png should be yellow. but it's not.
I'v tried install other packages, like gtk+3.0-dev or gtk4.0-dev, but the results are the same.
appreciate it if you can give me some help, thanks.
The text was updated successfully, but these errors were encountered: