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

dia: 2017-06-22 → 2020-04-07 #84555

Closed
wants to merge 2 commits into from
Closed

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Apr 7, 2020

Motivation for this change

Getting rid of GNOME 2 package set #39976

cc @viric

Things done
  • [ x] Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

and reorder the attributes
@veprbl
Copy link
Member

veprbl commented Apr 7, 2020

On darwin this fails with

2020-04-07 04:35:09.971 dia[70685:3631021] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 

** (dia:70685): WARNING **: 04:35:10.471: Unable to find object type: GRAFCET - Step

** (dia:70685): WARNING **: 04:35:10.471: Unable to find object type: GRAFCET - Step

<many similar warnings>

** (dia:70685): WARNING **: 04:35:10.564: Unable to find object type: Flowchart - Predefined Process

** (dia:70685): WARNING **: 04:35:10.564: Unable to find object type: Standard - Box

** (dia:70685): CRITICAL **: 04:35:10.574: Couldn't find standard objects when looking for object-libs in '/nix/store/jbwri07nqs0qcybyv576rfr12id4n08v-dia-unstable-2020-04-07/lib/dia/'; exiting...

I came up with a following workaround:

diff --git a/pkgs/applications/graphics/dia/default.nix b/pkgs/applications/graphics/dia/default.nix
index 6eee16145a7..5acba6f5895 100644
--- a/pkgs/applications/graphics/dia/default.nix
+++ b/pkgs/applications/graphics/dia/default.nix
@@ -58,6 +58,12 @@ stdenv.mkDerivation {
       build-aux/post-install.py
   '';
 
+  postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
+    for dylib in "$out"/lib/dia/*.dylib; do
+      ln "''${dylib}" "''${dylib%.*}.so"
+    done
+  '';
+
   meta = with stdenv.lib; {
     description = "GNOME Diagram drawing software";
     homepage = "https://wiki.gnome.org/Apps/Dia";

After that dia launches it is more or less usable, except for some rendering problems:
dia

@jtojnar jtojnar force-pushed the dia-upgrade branch 2 times, most recently from 418ca5c to 8dbce49 Compare April 7, 2020 11:20
@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 7, 2020

@veprbl pushed a new revision, re-adding gtk-mac-integration-gtk2 and merging https://gitlab.gnome.org/GNOME/dia/-/merge_requests/68. Does that fix it for you?

@veprbl
Copy link
Member

veprbl commented Apr 7, 2020

@jtojnar Thank you for implementing the fix. It does what needs to be done, but misses some of the libraries:

$ ls -1 /nix/store/jaq7jss0hmlglpsjb4w7bjgp9g7y5rpx-dia-unstable-2020-04-07/lib/dia/
libaadl_objects.dylib
libcairo_filter.so
libcgm_filter.so
libchronogram_objects.dylib
libcustom_lines_objects.dylib
libcustom_objects.dylib
libdb_objects.dylib
libdxf_filter.so
liber_objects.dylib
libflowchart_objects.dylib
libfs_objects.dylib
libgrafcet_objects.dylib
libhpgl_filter.so
libistar_objects.dylib
libjackson_objects.dylib
libkaos_objects.dylib
liblayout_filter.so
libmetapost_filter.so
libmisc_objects.dylib
libnetwork_objects.dylib
libpdf_filter.so
libpgf_filter.so
libpixbuf_filter.so
libpostscript_filter.so
libpstricks_filter.so
libpython_plugin.so
libsadt_objects.dylib
libshape_filter.so
libstandard_objects.dylib
libsvg_filter.so
libuml_objects.dylib
libvdx_filter.so
libwpg_filter.so
libxfig_filter.so
libxslt_filter.dylib

Regarding the rendering issues, I don't see much change. I've played with a window a bit more, I've noticed it blanks the window on resize, but depending on the size of the window three different things can happen. If the window is "smaller", it will render window as black (which macOS seems to screenshot as transparent color):

dia black

If it is "bigger" it actually renders the proper grey background and able to render most of the icons:

dia grey

And, finally, excessively small windows will be black, but will turn to white garbled texture on mouse hover (see my first screenshot for example).

Most buts get redrawn on mouse hover, so this is almost usable.

zlib
cairo
] ++ stdenv.lib.optionals stdenv.isDarwin [
gtk-mac-integration-gtk2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like this is used:

# grep -ri gtk_mac src/
# grep -ri gtk-mac src/
#

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect it to be somehow magically linked. Is it not listed in nix-store --query --tree or nix why-depends?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# nix-store --query --tree /nix/store/qflajk99al4hk1893gz6z2m996x6l930-dia-0.97.3.20170622 | grep mac
+---/nix/store/brvfal9n3wi562r98q1rgicxcjlyh7i1-gtk-mac-integration-2.0.8
|   +---/nix/store/brvfal9n3wi562r98q1rgicxcjlyh7i1-gtk-mac-integration-2.0.8 [...]
# nix-store --query --tree /nix/store/jaq7jss0hmlglpsjb4w7bjgp9g7y5rpx-dia-unstable-2020-04-07 | grep mac
#

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I can still grep GtkosxApplication in the source code. Looks like HAVE_MAC_INTEGRATION was not ported to Meson.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strangely enough, old dia also doesn't have the bug:

Screenshot 2020-04-07 at 17 01 29

And it does use the system menubar, like it's supposed to do with gtk-mac-integration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the latest change help?

Copy link
Member

@veprbl veprbl Apr 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtojnar The build is now failing with

../app/interface.c:1060:34: error: use of undeclared identifier 'dia_app_icon'
        gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL));
                                        ^
1 error generated.

After applying

diff --git a/app/interface.c b/app/interface.c
--- a/app/interface.c
+++ b/app/interface.c
@@ -1057,7 +1057,7 @@ _create_mac_integration (GtkWidget *menubar)
     gtk_widget_hide (menubar); /* not working, it's shown elsewhere */
     /* setup the dock icon */
     gtkosx_application_set_dock_icon_pixbuf (theOsxApp,
-       gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL));
+       pixbuf_from_resource ("/org/gnome/Dia/icons/org.gnome.Dia.png"));
   }
   /* Don't quit without asking to save files first */
   g_signal_connect (theOsxApp, "NSApplicationBlockTermination",

I get it to compile and run. I now get a proper dia icon in the dock and system-wide menu works again. There is no improvement with rendering.

@veprbl
Copy link
Member

veprbl commented Apr 7, 2020

Just tested 2889df2a66e, it starts up fine.

edit: no dylibs in $out/lib/dia anymore

@ZanderBrown
Copy link

Just checking: Your shipping this as unstable/testing/devel right?

@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 7, 2020

@ZanderBrown Yup, we use dia-unstable as the package name.

@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 8, 2020

@veprbl Would you be willing to bisect the graphical glitches? Should take roughly eight steps.

(You would run git bisect start master b86085dfe2b048a2d37d587adf8ceba6fb8bc43c in the Dia repo, change the nixpkgs expression’s src to your dia checkout, and then build it and try to run it and mark the bisection step with git bisect good/bad.)

* Upgrade three years old git snapshot to a fresh one
    * Switches to Meson
    * Drops GNOME 2 dependencies
@veprbl
Copy link
Member

veprbl commented Apr 8, 2020

@jtojnar
The bisect didn't go as smooth as planned. Many builds failed for various reasons and there was some bug that caused dia to crash on start. I patched couple of the bugs on the go and arrived to the following expression:

with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "dia";

  src = lib.cleanSource ./diagit;

  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    gettext
    python3 # for install script
    gtk2 # for gtk-update-icon-cache
    #libxslt # for xsltproc
    desktop-file-utils
    intltool
  ];

  buildInputs = [
    glib
    gtk2
    libxml2
    python2
    zlib
    cairo
  ];

  postPatch = ''
    patchShebangs \
      generate_run_with_dia_env.sh \
      build-aux/post-install.py
    substituteInPlace plug-ins/wmf/wmf.cpp \
      --replace '#include "config.h"' ""
    substituteInPlace objects/standard/outline.c \
      --replace '#include "tool-icons.h"' ""
  '';

  postInstall = ''
    for dylib in "$out"/lib/dia/*.dylib; do
      ln "''${dylib}" "''${dylib%.*}.so"
    done
  '';
}

What I learned was that there is a "good" version of dia that is able to be built with this (or a similar) meson-based expression, which is close enough to what you propose in this PR.

edit: updated bisect result after fixing more irrelevant failures

There are only 'skip'ped commits left to test.
The first bad commit could be any of:
651f7eb4810de4f94f04a106b0a45eb0495b1381
fd5d59244fd92909896c640578a6fca940aef47f
642282d842de4e59a06c0d7b53418683352a6a65
ea21bcab9d8740cbf7feef81359525128734cea6
665f9429dc7ad9a27cc6c0c265e586f37a5db33a
c1ec976f1e450fc5cc9873b929db0bf3b96b90ae
659179878502e515b6748c3e76dd3d51422a1925
ff4c247dea72c436e0c3b206039eb7e72dd60c6c
1b7726cd9044852af07fa296e2722237ef1878ee
af3c7836c0bf9aa7ac62fbac9a3dd569a9c3db81
9927ab22db91508f594f1d31f365cd02631e6c28
d0137e84d8cb47feb873911fd49ae18ff180c9bc
33e5aaa3585f040898159bc16d1d7ca67523b0de
d0339fa23a511feb44e653655dd24b191bf6b899
5654328926b2b4872b4e6056c3bf51adf47b0fa2
5e148bac88bded7d9e21f34b2f30f24ae0c1e9eb
1bef8c839986ec6ca89a44061154c483e3a19281
We cannot bisect more!

@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 8, 2020

Yeah, unfortunately, it is not easy to automate it. At best you will be able to keep automake & co. and preConfigure from the original expression and use the following hack to disable meson when not available:

  ${if builtins.pathExists "${src}/meson.build" then null else "dontUseMesonConfigure"} = true;
  ${if builtins.pathExists "${src}/meson.build" then null else "dontUseNinjaBuild"} = true;
  ${if builtins.pathExists "${src}/meson.build" then null else "dontUseNinjaInstall"} = true;

With 8 steps, it is also feasible, if annoying, to run the bisection manually.

@veprbl
Copy link
Member

veprbl commented Apr 8, 2020

@jtojnar I think you got me wrong. The breakage happened after meson was introduced. I am now trying to bisect the crash to learn how to fix it and, maybe, narrow down the search.

@veprbl
Copy link
Member

veprbl commented Apr 8, 2020

I guess, this has to do with new cairo renderer in dia.

@ZanderBrown
Copy link

Most likely, interestingly Windows & X11 haven't had an issue like that with rendering the canvas

However as of a few days ago line/arrow chooser in the properties dialogue do, except that code hasn't changed in months

It seems when rendering goes wrong in gtk2 it goes really wrong

@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 8, 2020

The question is do we ship this, or wait for a fix (possibly GTK 3 port)?

@veprbl
Copy link
Member

veprbl commented Apr 8, 2020

@jtojnar I would suggest we pin dia to a latest pre-cairo version for darwin. I can prepare a change for that.

@ZanderBrown
Copy link

This exact version? I'd say no, even as an unstable package that's way too broken

Of course I'm interested what's going on, especially as it's almost certainly my fault. Might try a VM at somepoint

@jtojnar jtojnar added the 2.status: wait-for-upstream Waiting for upstream fix (or their other action). label Apr 8, 2020
@veprbl
Copy link
Member

veprbl commented Apr 8, 2020

@ZanderBrown Let me know if there is anything I can try to help debugging this.

@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 8, 2020

Okay, since it does not really improve that much and it is far from the worst gnome2 library usage offender 😿, we will table this PR for now.

@ZanderBrown
Copy link

far from the worst gnome2 library usage offender

What is it using? if it's libgnomeui there is a configure flag for that

@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 8, 2020

libart_lgpl and libgnomeui

@ZanderBrown
Copy link

Ah well until we figure out the cairo issue libart_lgpl is sticking around, for libgnomeui just --disable it, isn't needed

@jtojnar jtojnar marked this pull request as draft May 25, 2020 12:39
@veprbl veprbl mentioned this pull request Jan 30, 2021
10 tasks
@stale
Copy link

stale bot commented Jun 4, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 4, 2021
@armeenm
Copy link
Contributor

armeenm commented Apr 25, 2022

Any updates on this?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 25, 2022
@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 25, 2022

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 30, 2022
@veprbl
Copy link
Member

veprbl commented Jan 8, 2023

Superseded by #209587

@veprbl veprbl closed this Jan 8, 2023
Picking up garbage automation moved this from In progress to Done Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: wait-for-upstream Waiting for upstream fix (or their other action). 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 1-10 10.rebuild-linux: 1
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants