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

Build VIPSDISP on windows #21

Closed
euzada opened this issue Sep 13, 2023 · 46 comments
Closed

Build VIPSDISP on windows #21

euzada opened this issue Sep 13, 2023 · 46 comments

Comments

@euzada
Copy link

euzada commented Sep 13, 2023

Hi @jcupitt, is there any way I can build vipsdip on Windows? I successfully built it from source on ubuntu, and I tried to install everything I needed on MINGW64. The problem I faced is in meson.build find_library 'm', so I bypass it using cc.find_library('m', required: false). But when I try to run ninja I got a lot of errors.
here a copy of part of errors:
FAILED: src/vipsdisp.exe.p/meson-generated_.._vipsdispmarshal.c.obj "cl" "-Isrc/vipsdisp.exe.p" "-Isrc" "-I../src" "-IC:/msys64/mingw64/include/libgsf-1" "-IC:/msys64/m ingw64/include/libxml2" "-IC:/msys64/mingw64/include/" "-IC:/msys64/mingw64/include/pango-1.0" "-IC: /msys64/mingw64/include/harfbuzz" "-IC:/msys64/mingw64/include/fribidi" "-IC:/msys64/mingw64/include /librsvg-2.0" "-IC:/msys64/mingw64/include/gdk-pixbuf-2.0" "-IC:/msys64/mingw64/include/webp" "-IC:/ msys64/mingw64/include/cairo" "-IC:/msys64/mingw64/include/freetype2" "-IC:/msys64/mingw64/include/l ibpng16" "-IC:/msys64/mingw64/include/pixman-1" "-IC:/msys64/mingw64/include/OpenEXR" "-IC:/msys64/m ingw64/include/Imath" "-IC:/msys64/mingw64/include/openjpeg-2.5" "-IC:/msys64/mingw64/include/orc-0. 4" "-IC:/msys64/mingw64/include/glib-2.0" "-IC:/msys64/mingw64/lib/glib-2.0/include" "-IC:/msys64/mi ngw64/include/gtk-4.0" "-IC:/msys64/mingw64/include/graphene-1.0" "-IC:/msys64/mingw64/lib/graphene- 1.0/include" "-I." "/MDd" "/nologo" "/showIncludes" "/utf-8" "/W2" "/std:c11" "/Od" "/Zi" "-DHAVE_CO NFIG_H" "-mfpmath=sse" "-msse" "-msse2" "-DLIBDEFLATE_DLL" "/Fdsrc/vipsdisp.exe.p/meson-generated_.. _vipsdispmarshal.c.pdb" /Fosrc/vipsdisp.exe.p/meson-generated_.._vipsdispmarshal.c.obj "/c" src/vips dispmarshal.c CreateProcess failed: The system cannot find the file specified.

Any suggestions?

@jcupitt
Copy link
Owner

jcupitt commented Sep 13, 2023

Hi @euzada,

I would start with the libvips build system:

https://github.com/libvips/build-win64-mxe

And add the various gtk4 binaries.

@kleisauke
Copy link
Contributor

The vipsdisp branch adds support for this. It seems to build successfully and works as intended.

Screenshot 2023-10-26 184708

To build locally, you can use:

$ git clone -b vipsdisp https://github.com/libvips/build-win64-mxe.git
$ cd build-win64-mxe/
$ ./build.sh web x86_64 shared --with-disp

@jcupitt
Copy link
Owner

jcupitt commented Oct 26, 2023

Woah, that's fantastic Kleis! Nice job!

What's performance like? Can you zoom smoothly on large images?

@kleisauke
Copy link
Contributor

Zooming and panning on large images also appear to be seamless; I think the performance is on par with that on Linux. See for example this screencast:

vipsdisp_c3495sdc4u.mp4

The only minor thing I noticed is that the icon for the previous and next page is broken.
Screenshot 2023-10-26 192319

@jcupitt
Copy link
Owner

jcupitt commented Oct 26, 2023

I suppose that's a problem with the icon theme?

What if you hold down i? It's supposed to do a smooth 60fps zoom on the mouse pointer.

@kleisauke
Copy link
Contributor

kleisauke commented Oct 26, 2023

Yeah, it looks like a theme issue. Here's a screencast while holding down i.

vipsdisp_lK2Jv9nTom.mp4

@jcupitt
Copy link
Owner

jcupitt commented Oct 26, 2023

So ... hot. I'll try a build here.

@jcupitt
Copy link
Owner

jcupitt commented Oct 26, 2023

I noticed a tiny thing on ubuntu 23.04 -- I see:

$ ./build.sh web x86_64 shared --with-disp
Error: short-name "buildpack-deps:bullseye" did not resolve to an alias and no unqualified-search registries are defined in "/etc/containers/registries.conf"

I had to disable podman by editing build.sh.

@euzada
Copy link
Author

euzada commented Oct 27, 2023

What a good news. Thank you @kleisauke and @jcupitt for sharing. I will try to build it tomorrow on my windows and leave you feedback after building and testing.

@euzada
Copy link
Author

euzada commented Oct 27, 2023

The vipsdisp branch adds support for this. It seems to build successfully and works as intended.

Screenshot 2023-10-26 184708

To build locally, you can use:

$ git clone -b vipsdisp https://github.com/libvips/build-win64-mxe.git
$ cd build-win64-mxe/
$ ./build.sh web x86_64 shared --with-disp

Hi @kleisauke , is that branch on the top of 8.15.0 rc1 or 8.14?

@kleisauke
Copy link
Contributor

is that branch on the top of 8.15.0 rc1 or 8.14?

It's based on top of v8.15.0-rc1, as required by vipsdisp v2.6.1.

vipsdisp/meson.build

Lines 40 to 41 in 3549634

# need vips_thread_execute()
vips_dep = dependency('vips', version: '>=8.15')

@kleisauke
Copy link
Contributor

$ ./build.sh web x86_64 shared --with-disp
Error: short-name "buildpack-deps:bullseye" did not resolve to an alias and no unqualified-search registries are defined in "/etc/containers/registries.conf"

I had to disable podman by editing build.sh.

I think this patch would also fix that:

--- a/build.sh
+++ b/build.sh
@@ -186,7 +186,7 @@ fi
 mkdir -p $tmpdir
 
 # Ensure latest Debian stable base image
-$oci_runtime pull buildpack-deps:bullseye
+$oci_runtime pull docker.io/library/buildpack-deps:bullseye
 
 # Create a machine image with all the required build tools pre-installed
 $oci_runtime build -t libvips-build-win-mxe container
--- a/container/Dockerfile
+++ b/container/Dockerfile
@@ -1,4 +1,4 @@
-FROM buildpack-deps:bullseye
+FROM docker.io/library/buildpack-deps:bullseye
 
 RUN apt-get update \
   && apt-get install -y \

But indeed, perhaps I should disable that Podman in favor of Docker if-else statement, since Fedora/RHEL also have an RPM called podman-docker, which can be used as a drop-in placement for the docker utility.

@euzada
Copy link
Author

euzada commented Oct 27, 2023

The build was successful. It builds V8.15.0 rc1 and vipsdisp.exe (V2.6.0). Loaded a very large image (7.5GB ) with no issues. The previous and next page icons are missing as mentioned previously.

@jcupitt
Copy link
Owner

jcupitt commented Oct 27, 2023

We should make a list of small issues with the win build, since we're all looking at it. I noticed:

  • missing icon theme
  • missing theme
  • no dbus.exe, leading to slow startup ... we could disable dbus integration (is it useful on win? I'm not sure) or include the exe in the build (probably not worth it)
  • drag and drop for file loading would be nice (nip2 on win has this, it was simple to support back then at least)
  • if you fullscreen, the right-click menu stops working (why?? how odd) and you have to press F11 to get back to windowed mode
  • does not set the "I'm a GUI" flag on the exe, so you get a stray terminal window

Are there any others?

@euzada
Copy link
Author

euzada commented Oct 27, 2023

When I first open the executable I see terminal with:
(vipsdisp.exe:17092): GLib-GIO-WARNING **: 15:06:47.724: win32 session dbus binary not found

Than when I tried to save an image in another tiff format, I got:

(vipsdisp.exe:17092): GLib-GObject-CRITICAL **: 15:06:57.945: ../glib-2.78.1/gobject/gsignal.c:2451: signal id '0' is invalid for instance '00000262ee2848b0'

(vipsdisp.exe:17092): GLib-GObject-CRITICAL **: 15:06:57.948: ../glib-2.78.1/gobject/gsignal.c:2451: signal id '0' is invalid for instance '00000262ee2849f0'

(vipsdisp.exe:17092): GLib-GObject-CRITICAL **: 15:06:58.056: ../glib-2.78.1/gobject/gsignal.c:2677: instance '00000262ee2849f0' has no handler with id '0'

(vipsdisp.exe:17092): GLib-GObject-CRITICAL **: 15:06:58.059: ../glib-2.78.1/gobject/gsignal.c:2730: instance '00000262ee2849f0' has no handler with id '0'
Unknown type for property "keep"

@kleisauke
Copy link
Contributor

I also noticed:

  • no dbus.exe, leading to slow startup ... we could disable dbus integration (is it useful on win? I'm not sure) or include the exe in the build (probably not worth it)

I've tentatively "fixed" this with commit libvips/build-win64-mxe@6ad6917. I'm not sure if D-Bus integration can be disabled, it looks like a required thing.

(vipsdisp.exe:17092): GLib-GObject-CRITICAL **: 15:06:57.945: ../glib-2.78.1/gobject/gsignal.c:2451: signal id '0' is invalid for instance '00000262ee2848b0'

(vipsdisp.exe:17092): GLib-GObject-CRITICAL **: 15:06:57.948: ../glib-2.78.1/gobject/gsignal.c:2451: signal id '0' is invalid for instance '00000262ee2849f0'

(vipsdisp.exe:17092): GLib-GObject-CRITICAL **: 15:06:58.056: ../glib-2.78.1/gobject/gsignal.c:2677: instance '00000262ee2849f0' has no handler with id '0'

(vipsdisp.exe:17092): GLib-GObject-CRITICAL **: 15:06:58.059: ../glib-2.78.1/gobject/gsignal.c:2730: instance '00000262ee2849f0' has no handler with id '0'
Unknown type for property "keep"

I'm not sure about those gsignal errors, but the Unknown type for property "keep" warning can be fixed by adding a case for G_IS_PARAM_SPEC_FLAGS( pspec ) in save_options_add_option(), similar to G_IS_PARAM_SPEC_ENUM( pspec ).

else if( G_IS_PARAM_SPEC_ENUM( pspec ) ) {

(adding support for flags as save option would also make VipsForeignPngFilter work)

@jcupitt
Copy link
Owner

jcupitt commented Oct 28, 2023

Ah you're right, the save-as dialog is missing some stuff, and doesn't resize too well. I have to make a long train journey today, I'll have a poke at it.

@jcupitt
Copy link
Owner

jcupitt commented Oct 28, 2023

I fixed up sizing and added flags support, so that resolved the keep message, I think.

@jcupitt
Copy link
Owner

jcupitt commented Oct 28, 2023

Save as TIFF seems to work fine on linux, perhaps there's a win issue here?

@euzada
Copy link
Author

euzada commented Oct 30, 2023

I build the latest update.

  1. Now, the gdbus.exe is compiled and created in the bin folder and the first error (vipsdisp.exe:17092): GLib-GIO-WARNING **: 15:06:47.724: win32 session dbus binary not found is fixed.

  2. The template icons are now working.

  3. The Unknown type for property "keep" is also fixed.

  4. Saving the Tiff (or tif) is completed successfully with these information in terminal. but the save works. Hope this is helpful.

(vipsdisp.exe:22024): GLib-GObject-CRITICAL **: 09:38:38.900: ../glib-2.78.1/gobject/gsignal.c:2451: signal id '0' is invalid for instance '0000022ea0be0a10'

(vipsdisp.exe:22024): GLib-GObject-CRITICAL **: 09:38:38.905: ../glib-2.78.1/gobject/gsignal.c:2451: signal id '0' is invalid for instance '0000022ea0be0910'

(vipsdisp.exe:22024): GLib-GObject-CRITICAL **: 09:38:38.996: ../glib-2.78.1/gobject/gsignal.c:2677: instance '0000022ea0be0910' has no handler with id '0'

(vipsdisp.exe:22024): GLib-GObject-CRITICAL **: 09:38:38.998: ../glib-2.78.1/gobject/gsignal.c:2730: instance '0000022ea0be0910' has no handler with id '0'
  1. Notice that "i" and "o" are not smooth anymore. it zoom/dezoom with glitch/freeze for fraction of second from time to time.

@jcupitt
Copy link
Owner

jcupitt commented Oct 30, 2023

That's great! Is app startup faster? It was quite slow before. It ought to pop up a window almost instantly.

I don't know what's causing the signal errors, I don't see them here :( Some gtk/glib compat issue, perhaps?

i/o not being smooth can happen with some file formats. Are files that were smooth before hitching now?

@euzada
Copy link
Author

euzada commented Oct 30, 2023

That's great! Is app startup faster? It was quite slow before. It ought to pop up a window almost instantly.

I don't know what's causing the signal errors, I don't see them here :( Some gtk/glib compat issue, perhaps?

i/o not being smooth can happen with some file formats. Are files that were smooth before hitching now?

I check the previous version, the i/o where not smooth. So maybe it is my file size. Will generate smaller file and test again.
Is there any way to load it without opening Terminal first?

@jcupitt
Copy link
Owner

jcupitt commented Oct 30, 2023

Windows .exe files have a special flag inside for "I'm a GUI app". If this is not set, Windows will automatically make a terminal and display program input and output.

We just need to set a compiler flag when linking vipsdisp.exe ... I forget what it's called.

@jcupitt
Copy link
Owner

jcupitt commented Oct 30, 2023

Ah, setting -mwindows when linking vipsdisp.exe, I think. We might also need to define WinMain(), I'm not sure.

@kleisauke
Copy link
Contributor

kleisauke commented Oct 30, 2023

It looks like specifying win_subsystem: 'windows' in Meson's executable() function would fix that.
https://mesonbuild.com/Reference-manual_functions.html#executable_win_subsystem
https://github.com/GNOME/gtk/blob/020ef51cb00fdf0e4a440468d41ed8256881da17/demos/widget-factory/meson.build#L71

I'll try a patch and also investigate those signal errors.

@euzada
Copy link
Author

euzada commented Oct 30, 2023

That's great! Is app startup faster? It was quite slow before. It ought to pop up a window almost instantly.

I did some test using the following command in bash for windows and did not see any difference in the latest version.
time "E:\vips-dev-8.15\bin\vipsdisp.exe" | ps ax | grep vipsdisp | grep -v grep | awk '{print $1}' | xargs kill

I don't know if I should run a different command.

The output was something like that for both versions:

real    0m1.080s
user    0m0.015s
sys     0m0.321s

@jcupitt
Copy link
Owner

jcupitt commented Oct 30, 2023

Oh, clever idea. Perhaps it's just slow to load all those DLLs? There are a lot of them. A static build might be faster.

@euzada
Copy link
Author

euzada commented Oct 30, 2023

I build it with the following command:

./build.sh web x86_64 shared --with-disp

Do I try static build?

@jcupitt
Copy link
Owner

jcupitt commented Oct 30, 2023

Yes, try static.

I tried this in vipsdispapp.c:

static void
vipsdisp_app_activate( GApplication *app )
{
    ImageWindow *win;

    win = image_window_new( VIPSDISP_APP( app ) );
    gtk_window_present( GTK_WINDOW( win ) );
    process_events();
    exit(0);
}

ie. on startup, show the main window, process a few events, then quit. On ubuntu I see:

$ time vipsdisp 

real	0m0.200s
user	0m0.160s
sys	0m0.075s

which feels fast.

@euzada
Copy link
Author

euzada commented Oct 30, 2023

Yes, try static.

I tried this in vipsdispapp.c:

static void
vipsdisp_app_activate( GApplication *app )
{
    ImageWindow *win;

    win = image_window_new( VIPSDISP_APP( app ) );
    gtk_window_present( GTK_WINDOW( win ) );
    process_events();
    exit(0);
}

ie. on startup, show the main window, process a few events, then quit. On ubuntu I see:

$ time vipsdisp 

real	0m0.200s
user	0m0.160s
sys	0m0.075s

which feels fast.

I am getting this error trying to build it with static flag like that: ./build.sh web x86_64 static --with-disp

ERROR: GTK cannot be built as a statically linked library on Windows.

@jcupitt
Copy link
Owner

jcupitt commented Oct 30, 2023

You need to build libvips static, then vipsdisp dynamic.

@kleisauke
Copy link
Contributor

The vipsdisp branch has been updated to incorporate this. I'll have a look at the disabled static build and GUI app hint tomorrow.

@jcupitt
Copy link
Owner

jcupitt commented Nov 1, 2023

It looks like specifying win_subsystem: 'windows' in Meson's executable() function would fix that.

Oh nice find, I added that to src/meson.build

@kleisauke
Copy link
Contributor

Great! I can confirm that commit ff7b8cb removes the stray terminal window.

To avoid having to spend any extra CPU time building these binaries, I've uploaded the 64-bit libvips 8.15.0-rc1 Windows binaries with vipsdisp here:
https://libvips-packaging.s3.amazonaws.com/vips-dev-w64-web-8.15.0-rc1-disp.zip
https://libvips-packaging.s3.amazonaws.com/vips-dev-w64-all-8.15.0-rc1-disp.zip
(these binaries were built against commit libvips/build-win64-mxe@9c86ee1)

@euzada
Copy link
Author

euzada commented Nov 1, 2023

I can confirm no Terminal at the start. and Save windows use Windows explorer. I will do some test for the speed later today.

Thank you.

@jcupitt
Copy link
Owner

jcupitt commented Nov 1, 2023

I tried out "loupe", the new gtk4 image viewer that gnome have made:

https://gitlab.gnome.org/GNOME/loupe

With st-francis.jpg:

$ vipsheader st-francis.jpg
st-francis.jpg: 30000x26319 uchar, 3 bands, srgb, jpegload

The version in ubuntu 23.10 loads the image in 13.5s and needs 7.5gb of memory. Panning needs maybe 8% of CPU on my PC. It's nice and smooth.

The Gnome nightly build of Loupe loads in 13.5s again, but only needs 2.3gb of memory, so they've made some good improvements there. CPU use seems about the same.

On this ubuntu 23.10 PC, a release build of vipsdisp loads the image in 8s and needs 1.3gb of memory. Panning is about 15% of CPU. We're a little less smooth.

So we win on load speed and memory use, as you'd hope heh. We could probably get CPU use down --- at the moment, vipsdisp culls tiles to the viewport every frame, but we only really need to cull on tile boundaries. It might improve the frame rate too.

They have much slower mousewheel zoom, so we could maybe tune that.

@jcupitt
Copy link
Owner

jcupitt commented Nov 1, 2023

... I tuned the zoom speed and initial window size to match loupe.

@euzada
Copy link
Author

euzada commented Nov 1, 2023

I don't know if on windows it is the same. When I try to zoom on my PC, The GPU is the one how manage the zoom and increased to almost 10% while zooming (I believe it is good things) . Do you see any GPU increase on Linux?

@jcupitt
Copy link
Owner

jcupitt commented Nov 1, 2023

Yes, it uses the GPU on linux too.

@euzada
Copy link
Author

euzada commented Nov 1, 2023

I start a fresh build. I am not sure it will apply to the loupe integration. It will take time to build llvm.
I use git config pull.rebase true and it said:

Updating 7681c50a..c185fad1
Fast-forward
 docs/build-matrix.html | 6 +++---
 docs/packages.json     | 6 +++---
 src/freetds.mk         | 4 ++--
 src/libjpeg-turbo.mk   | 4 ++--
 src/openssl.mk         | 4 ++--
 5 files changed, 12 insertions(+), 12 deletions(-)

Do you know if this will apply to loupe integration?

@jcupitt
Copy link
Owner

jcupitt commented Nov 1, 2023

There's no loupe integration, I was just benchmarking it for comparison.

@jcupitt
Copy link
Owner

jcupitt commented Nov 1, 2023

Oh, you mean the changes to vipsdisp to match loupe? You'd need to change vipsdisp.mk to build git master.

@euzada
Copy link
Author

euzada commented Nov 1, 2023

Yes, this is what I meant. I test the last build and it takes 70ms for the GUI to start. I used Measure-Command {.\vipsdisp.exe} in PowerShell.

@euzada
Copy link
Author

euzada commented Nov 1, 2023

  • if you fullscreen, the right-click menu stops working (why?? how odd) and you have to press F11 to get back to windowed mode

In Full screen with F11, the menu will be hidden behind the GUI in the background. If you do "Windows + d" to see the desktop than do it again "Win + d" the menu will appear on the front. I believe the solution is to force the right-click menu to always be on the top.

We should probably add something like that for the menu: gtk_window_set_keep_above(GTK_WINDOW(window), TRUE); as explained in the following link: [Bug 171456 - "Keep Above" option in Gimp broken on Win32](https://bugzilla.gnome.org/show_bug.cgi?id=171456)

@jcupitt
Copy link
Owner

jcupitt commented Nov 13, 2023

In Full screen with F11, the menu will be hidden behind the GUI in the background. If you do "Windows + d" to see the desktop than do it again "Win + d" the menu will appear on the front.

Ah, interesting!

gtk4 doesn't have keep_above (gimp is still on gtk2 I think):

https://docs.gtk.org/gtk4/class.Window.html

vipsdisp uses the same menu for the burger button on the header bar, and right-click on the image. Maybe this is the cause? Perhaps we ought to use separate menus, or remove the right-click menu?

@jcupitt
Copy link
Owner

jcupitt commented Apr 9, 2024

I think this is all done now.

@jcupitt jcupitt closed this as completed Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants