Skip to contentSkip to conversation

Work around errors of unstable Inkscape

PATCH In review Akira Yokosawa 2 participants 7 messages Oct 13, 2023 – Oct 14, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Work around errors of unstable Inkscape

Hi Paul,

I expected the crashing bug in Fedora's distro Inkscape would be resolved by the time of Fedora 39 release.
I tested Fedora 39 beta and was disappointed to see more or less the same crashes of command-line runs of Inkscape as those under Fedora 38.

As a matter of fact, even when Inkscape crashes, the export of PDF is complete most of the time. So the crashing bug can be worked around by ignoring the error code from Inkscape and continue building.

This patch set implements the ad-hoc workaround in build scripts.

As you can see in Patch 1/3, the workaround is enabled by default. This is because enabling it won't do any harm on systems with stable Inkscape.

I might be able to add some heuristics not to enable the workaround for stable Inkscape installs, but that can wait.

Ubuntu releases 22.04LTS, 23.04, and 23.10 are free of this issue.

Thanks, Akira
--
Akira Yokosawa (3):
Ignore error of unstable Inkscape
Ignore emergency-save SVG files from Inkscape
Make sure all PDF conversions are complete

 .gitignore |  1 +
 Makefile   | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

base-commit: 84759ebac65a03aa28c5b02007e6c472b3416d3d

Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 Ignore error of unstable Inkscape

Recently, conversions of SVG --> PDF are hit by unstability of command-line runs of Inkscape under the GNOME session/window manager.

There is an issue ticket at the upstream Inkscape repository [1].

It was closed after a bugfix in glib2, but Fedora 38 has not received the fix. Furthermore, pre-release Fedora 39, as well as openSUSE tumbleweed, still has the very similar symptoms.

As a matter of fact, the conversion is properly finished most of the time when the Inkscape error happened.

So let's add a make variable IGNORE_INKSCAPE_ERROR and ignore error code from Inkscape when it is enabled. It is enabled by default.

[1] Issue #4177 "glib2 2.76.0 breaks Command Line export" at
https://gitlab.com/inkscape/inkscape/-/issues/

---
 Makefile | 5 +++++
 1 file changed, 5 insertions(+)
Makefile +5 -0
index f25baf27d8ad..18639b60cece 100644
@@ -109,6 +109,7 @@ INKSCAPE := $(shell $(WHICH) inkscape 2>/dev/null)
 ifdef INKSCAPE
   INKSCAPE_ONE := $(shell inkscape --version 2>/dev/null | grep -c "Inkscape 1")
 endif
+IGNORE_INKSCAPE_ERROR ?= 1
 LATEXPAND := $(shell $(WHICH) latexpand 2>/dev/null)
 QPDF := $(shell $(WHICH) qpdf 2>/dev/null)
 
@@ -481,7 +482,11 @@ endif
 ifeq ($(INKSCAPE_ONE),0)
 	@inkscape --export-pdf=$@ $<i > /dev/null 2>&1
 else
+  ifneq ($(IGNORE_INKSCAPE_ERROR),0)
+	-@inkscape -o $@ $<i > /dev/null 2>&1
+  else
 	@inkscape -o $@ $<i > /dev/null 2>&1
+  endif
 endif
 	@rm -f $<i
 ifeq ($(chkpagegroup),on)
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/3 Ignore emergency-save SVG files from Inkscape

In reply to Akira Yokosawa

When Inkscape is terminated by an error, it saves the SVG file it was processing into an emergency-save SVG file.

In perfbook, this results in extra SVG files such as:

- advsync/rt-regimes.svgi.2023_MM_DD_hh_mm_ss.0.svg
- datastruct/hashzu-a.svgi.2023_MM_DD_hh_mm_ss.0.svg

Ignore those files in successive runs of make and remove them in "make clean", "make cleanfigs", and "make cleanfigs-svg".

Update .gitignore as well.

---
 .gitignore | 1 +
 Makefile   | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
.gitignore +1 -0
index fa20ccb5de94..ce93394f53b1 100644
@@ -19,6 +19,7 @@
 *.epsi
 *__.eps
 *.svgi
+*.svg*.svg
 *.fcv
 *.ltms
 *.pdfp
Makefile +5 -3
index 18639b60cece..6e220c2db524 100644
@@ -52,7 +52,9 @@ FIGSOURCES := $(wildcard */*.fig) $(wildcard */*/*.fig)
 
 EPSSOURCES_FROM_FIG := $(FIGSOURCES:%.fig=%.eps)
 
-SVGSOURCES := $(wildcard */*.svg)
+SVGSOURCES_ALL := $(wildcard */*.svg)
+SVG_EMERGENCY := $(wildcard */*.svg*.svg)
+SVGSOURCES := $(filter-out $(SVG_EMERGENCY),$(SVGSOURCES_ALL))
 FAKE_EPS_FROM_SVG := $(SVGSOURCES:%.svg=%.eps)
 PDFTARGETS_OF_SVG := $(SVGSOURCES:%.svg=%.pdf)
 
@@ -603,7 +605,7 @@ clean:
 	rm -f perfbook*.sil
 	rm -f CodeSamples/snippets.d
 	rm -f *.synctex*
-	@rm -f $(OBSOLETE_FILES) $(EPSSOURCES_TMP)
+	@rm -f $(OBSOLETE_FILES) $(EPSSOURCES_TMP) $(SVG_EMERGENCY)
 
 paper-clean:
 	rm -f $(BASE_DEPENDS)
@@ -627,7 +629,7 @@ cleanfigs-eps:
 	rm -f $(PDFTARGETS_OF_EPS)
 
 cleanfigs-svg:
-	rm -f $(PDFTARGETS_OF_SVG)
+	rm -f $(PDFTARGETS_OF_SVG) $(SVG_EMERGENCY)
 
 cleanfigs: cleanfigs-eps cleanfigs-svg
 
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/3 Make sure all PDF conversions are complete

In reply to Akira Yokosawa

Crashes of Inkscape can disturb parallel runs of SVG --> PDF conversions.

Add a sub-make run of "make -j1 figs" in the early stage of latex run to make sure any missing PDF figures can be prepared in time.

Note:
If GNUmake's dependency check is perfect, when there were any missing PDF files remaining, the recipe of autodate.tex shouldn't run. Unfortunately, it looks like that is not the case.

---
 Makefile | 4 ++++
 1 file changed, 4 insertions(+)
Makefile +4 -0
index 6e220c2db524..3875c52b1570 100644
@@ -267,6 +267,10 @@ endif
 autodate.tex: $(LATEXSOURCES) $(BIBSOURCES) $(LST_SOURCES) \
     $(PDFTARGETS_OF_EPS) $(PDFTARGETS_OF_SVG) $(FCVSNIPPETS) $(FCVSNIPPETS_VIA_LTMS) \
      $(GITREFSTAGS) utilities/autodate.sh
+ifneq ($(IGNORE_INKSCAPE_ERROR),0)
+	# Make sure all SVG --> PDF conversions are complete
+	$(MAKE) -j1 figs
+endif
 	sh utilities/autodate.sh
 
 perfbook_flat.tex: autodate.tex
Signature · 1 line
2.25.1
#4 lore raw
In reply to Akira Yokosawa
Quoted 13 lines · Akira Yokosawa

Hi Paul,

I expected the crashing bug in Fedora's distro Inkscape would be resolved by the time of Fedora 39 release.
I tested Fedora 39 beta and was disappointed to see more or less the same crashes of command-line runs of Inkscape as those under Fedora 38.

As a matter of fact, even when Inkscape crashes, the export of PDF is complete most of the time. So the crashing bug can be worked around by ignoring the error code from Inkscape and continue building.

This patch set implements the ad-hoc workaround in build scripts.

Quoted 8 lines

As you can see in Patch 1/3, the workaround is enabled by default. This is because enabling it won't do any harm on systems with stable Inkscape.

I might be able to add some heuristics not to enable the workaround for stable Inkscape installs, but that can wait.

Ubuntu releases 22.04LTS, 23.04, and 23.10 are free of this issue.

Ouch!

But look like a good approach. Queued and pushed, thank you!

Thanx, Paul

Quoted 16 lines

Thanks, Akira
--
Akira Yokosawa (3):
Ignore error of unstable Inkscape
Ignore emergency-save SVG files from Inkscape
Make sure all PDF conversions are complete

 .gitignore |  1 +
 Makefile   | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

base-commit: 84759ebac65a03aa28c5b02007e6c472b3416d3d

Signature · 1 line
2.25.1
#5 lore raw
In reply to Akira Yokosawa
Quoted 13 lines · Akira Yokosawa

Hi Paul,

I expected the crashing bug in Fedora's distro Inkscape would be resolved by the time of Fedora 39 release.
I tested Fedora 39 beta and was disappointed to see more or less the same crashes of command-line runs of Inkscape as those under Fedora 38.

As a matter of fact, even when Inkscape crashes, the export of PDF is complete most of the time. So the crashing bug can be worked around by ignoring the error code from Inkscape and continue building.

This patch set implements the ad-hoc workaround in build scripts.

Quoted 8 lines

As you can see in Patch 1/3, the workaround is enabled by default. This is because enabling it won't do any harm on systems with stable Inkscape.

I might be able to add some heuristics not to enable the workaround for stable Inkscape installs, but that can wait.

Ubuntu releases 22.04LTS, 23.04, and 23.10 are free of this issue.

No, Ubuntu 23.04 shows this symptom, rarer than Fedora but still...

Thanks, Akira

Quoted 14 lines

Thanks, Akira
--
Akira Yokosawa (3):
Ignore error of unstable Inkscape
Ignore emergency-save SVG files from Inkscape
Make sure all PDF conversions are complete

 .gitignore |  1 +
 Makefile   | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

base-commit: 84759ebac65a03aa28c5b02007e6c472b3416d3d

#6 lore raw
Quoted 18 lines · Akira Yokosawa
Quoted 17 lines · Akira Yokosawa

Hi Paul,

I expected the crashing bug in Fedora's distro Inkscape would be resolved by the time of Fedora 39 release.
I tested Fedora 39 beta and was disappointed to see more or less the same crashes of command-line runs of Inkscape as those under Fedora 38.

As a matter of fact, even when Inkscape crashes, the export of PDF is complete most of the time. So the crashing bug can be worked around by ignoring the error code from Inkscape and continue building.

This patch set implements the ad-hoc workaround in build scripts.

As you can see in Patch 1/3, the workaround is enabled by default. This is because enabling it won't do any harm on systems with stable Inkscape.

Quoted 6 lines
Quoted 4 lines

I might be able to add some heuristics not to enable the workaround for stable Inkscape installs, but that can wait.

Ubuntu releases 22.04LTS, 23.04, and 23.10 are free of this issue.

No, Ubuntu 23.04 shows this symptom, rarer than Fedora but still...

Even more reason for it to be applied, then. ;-)

Again, thank you!

Thanx, Paul

Quoted 16 lines

Thanks, Akira

Quoted 14 lines

Thanks, Akira
--
Akira Yokosawa (3):
Ignore error of unstable Inkscape
Ignore emergency-save SVG files from Inkscape
Make sure all PDF conversions are complete

 .gitignore |  1 +
 Makefile   | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

base-commit: 84759ebac65a03aa28c5b02007e6c472b3416d3d