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

Crash when paper size too large? #13

Closed
kjcole opened this issue Apr 10, 2022 · 29 comments
Closed

Crash when paper size too large? #13

kjcole opened this issue Apr 10, 2022 · 29 comments
Labels
bug Something isn't working
Milestone

Comments

@kjcole
Copy link

kjcole commented Apr 10, 2022

  • Python 3.8.10
  • LilyPond 2.20.0
  • Sphinx 4.4.0
  • sphinxnotes-lilypond 1.5
  • Wand 0.6.7

In order to make scores stay in a single file, I have been adding the following to the top of my Lilypond files:

\version "2.20.0"
\language "english"

% A4 = 210 mm * 297 mm
#(set! paper-alist
  (cons '("long scroll" . (cons (* 210 ) (* ??? mm))) paper-alist))

\paper {
  #(set-paper-size "long scroll")
}

I increase the value of ??? above until the entire score fits in a single page. This has worked fine with values up to 371, but today I had one that needed 440 and the build blew up with:

writing output... [ 85%] scotch/hundred_pipers                                               
Exception occurred:
  File "/home/kjcole/.local/lib/python3.8/site-packages/wand/resource.py", line 222, in raise_exception
    raise e
wand.exceptions.CoderError: No IDATs written into file `/tmp/sphinxnotes-lilypondbzouhve4/music.png' @ error/png.c/MagickPNGErrorHandler/1641
The full traceback has been saved in /tmp/sphinx-err-hj4x9frp.log, if you want to report the issue to the developers.

sphinx-err-hj4x9frp.log

@SilverRainZ SilverRainZ added the bug Something isn't working label Apr 13, 2022
@kjcole
Copy link
Author

kjcole commented Apr 20, 2022

More info: I have the resolution set to 600, and am generating PNGs. From your code, I pulled the arguments and manually ran

lilypond -o /tmp/sphinxnotes-lilypondfvinrg_w/ --formats png -dresolution=600 hundred_pipers.ly 

which generated a PNG with a file size of 1,017,890 bytes. If I use the default resolution (leaving the -dresolution=600 out) the file size shrinks to 126,896. (I'd prefer to keep the resolution high.)

However, running it through Sphinx using the Lilypond extension, it generates a 115-byte stub of a PNG:

0x00000000: 89504E47 0D0A1A0A 0000000D 49484452     .PNG........IHDR
0x00000010: 000011DA 00002781 08000000 00E65DE7     ......'.......].
0x00000020: 2A000000 02624B47 4400FF87 8FCCBF00     *....bKGD.......
0x00000030: 00000970 48597300 005C4600 005C4601     ...pHYs..\F..\F.
0x00000040: 14944341 00000007 74494D45 07E60414     ..CA....tIME....
0x00000050: 0B2A16B1 D8A2AF00 00001063 614E7600     .*.........caNv.
0x00000060: 00136100 00291E00 00009D00 0000A0B2     ..a..)..........
0x00000070: 8ACC70                                  ..p

@SilverRainZ
Copy link
Member

I am quite busy recently, will dig it this week :D

@kjcole
Copy link
Author

kjcole commented Apr 22, 2022

Take your time. I am not in any rush.

I've switched to SVGs (and filed a bug about cropping).

If you need me to switch back to PNGs (or send you the file that killed the extension) let me know.

@SilverRainZ
Copy link
Member

Hi @kjcole, I use the following rst source, and set lilypond_png_resolution = 600, still can not reproduce your problem, can your please provide me the score and directive you use?

.. lily::
   :noedge:
   :noedge:

   \version "2.20.0"
   \language "english"

   % A4 = 210 mm * 297 mm
   #(set! paper-alist
     (cons '("long scroll" . (cons (* 210 ) (* 440 mm))) paper-alist))

   \paper {
     #(set-paper-size "long scroll")
   }

   \header {
     title = "翼をください, Excerpts"
   }

   \score {
     <<
       \new Staff \relative c' {
           \time 4/4
           \tempo 4 = 70
           r4 r r c8 d                  e8 e f16 e8 d16 (d4) e8 d
           c8 c d16 c8 b16 (b4) b8 g    a4 c8 a g4 c4
           d4 r r r
     }
     >>
   }

@kjcole
Copy link
Author

kjcole commented May 22, 2022

I've recently upgraded to Pop!_OS 22.04 LTS.

This moved me from Python 3.8 to Python 3.10 and from LilyPond 2.20.0 to LilyPond 2.22.1. (It also changed a lot of other applications and libraries.)

I also found a better way to eliminate page-breaks. See the small patch in changes.txt

After downloading, remove the .txt added to the end of each file name below except for isonum.txt and changes.txt above. (I had to add it to satisfy GitHub.)

And from _static/:

I just ran it again after the major distribution release upgrade. The console log is:

$ make html
Running Sphinx v4.5.0
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 60 source files that are out of date
updating environment: [new config] 60 added, 0 changed, 0 removed
reading sources... [100%] welsh/index
looking for now-outdated files... none found
pickling environment... done
done
preparing documents... done
writing output... [ 85%] scotch/hundred_pipers
Exception occurred:
File "/home/kjcole/.local/lib/python3.10/site-packages/wand/resource.py", line 222, in raise_exception
raise e
wand.exceptions.CoderError: No IDATs written into file `/tmp/sphinxnotes-lilypondwkdaval8/music.png' @ error/png.c/MagickPNGErrorHandler/1642
The full traceback has been saved in sphinx-err-snfolw40.log
, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at https://github.com/sphinx-doc/sphinx/issues. Thanks!
make: *** [Makefile:20: html] Error 2

@kjcole
Copy link
Author

kjcole commented Jul 2, 2022

Any progress?

@SilverRainZ
Copy link
Member

SilverRainZ commented Jul 4, 2022

Sorry, not yet, I will take a look this week.

@kjcole
Copy link
Author

kjcole commented Jul 4, 2022

No rush. Just checking back.

@SilverRainZ
Copy link
Member

This song is beautiful :D

but I still can not reproduce it :(

Running Sphinx v4.5.0
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: [new config] 2 added, 0 changed, 0 removed
reading sources... [100%] index                                                                           
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/la/workspace/sphinxnotes-lilypond-bug13/hundred_pipers.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] index                                                                            
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 1 warning.

The HTML pages are in _build.

What is your version of imagemagick? I am using 7.1.0.41.

@SilverRainZ
Copy link
Member

However, running it through Sphinx using the Lilypond extension, it generates a 115-byte stub of a PNG:

@kjcole I don't know what is "stub of PNG"?

@SilverRainZ
Copy link
Member

Hi @kjcole, can you tell me your ImageMagick version?

@kjcole
Copy link
Author

kjcole commented Jul 15, 2022

What I meant by a stub of a PNG: It generated a file, and the first few bytes identify it as a PNG but after the header that identifies the image format, there is no data. Like a template with no content.

It looks like I'm using an older version of ImageMagick.

Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25

(dpkg says, specifically "8:6.9.11.60+dfsg-1.3build2")

@SilverRainZ
Copy link
Member

I will try your ImageMagick version.

@kjcole
Copy link
Author

kjcole commented Aug 14, 2022

It has taken me some time to get back to testing. This morning, I compiled the whole book again, and it successfully generated all the PNGs. So, either you fixed the problem, or some upgrade of something else fixed the problem. Probably a bit of both. Thanks.

(Before trying the PNGs, my conf.py was still set to SVGs, which now don't crop but were seriously degraded in quality. However, I'm happy with the PNGs. As long as I tell Lilypond that the paper is of "infinite length" I don't run into the badly scaled page problem.)

@kjcole kjcole closed this as completed Aug 14, 2022
@kjcole
Copy link
Author

kjcole commented Aug 15, 2022

I spoke too soon: I had left the conf.py at a 300 DPI resolution. When I set it back to 600, it crashed the on the same file.

@kjcole kjcole reopened this Aug 15, 2022
@SilverRainZ
Copy link
Member

Before trying the PNGs, my conf.py was still set to SVGs, which now don't crop but were seriously degraded in quality.

#18 improved the quality of cropped SVG, have you tried it?

@kjcole
Copy link
Author

kjcole commented Aug 16, 2022

Yes. I tried the SVG patch. See the console log below and the attached screenshot showing the seriously degraded SVG. (All of the SVGs are bad.)

sphinx-svg

$ pip install --user git+https://github.com/sphinx-notes/lilypond.git@bugfix/trim-svg
Collecting git+https://github.com/sphinx-notes/lilypond.git@bugfix/trim-svg
  Cloning https://github.com/sphinx-notes/lilypond.git (to revision bugfix/trim-svg) to /tmp/pip-req-build-db17jqqu
  Running command git clone --filter=blob:none --quiet https://github.com/sphinx-notes/lilypond.git /tmp/pip-req-build-db17jqqu
  Running command git checkout -b bugfix/trim-svg --track origin/bugfix/trim-svg
  Switched to a new branch 'bugfix/trim-svg'
  Branch 'bugfix/trim-svg' set up to track remote branch 'bugfix/trim-svg' from 'origin'.
  Resolved https://github.com/sphinx-notes/lilypond.git to commit 1ef93f54c3a97b17fcfa0dd276d92d2181c96a01
  Preparing metadata (setup.py) ... done
Requirement already satisfied: Sphinx>=1.6 in ./.local/lib/python3.10/site-packages (from sphinxnotes-lilypond==1.5.1) (5.1.1)
Requirement already satisfied: python-ly in /usr/lib/python3/dist-packages (from sphinxnotes-lilypond==1.5.1) (0.9.6)
Requirement already satisfied: wand in ./.local/lib/python3.10/site-packages (from sphinxnotes-lilypond==1.5.1) (0.6.9)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (21.3)
Requirement already satisfied: requests>=2.5.0 in /usr/lib/python3/dist-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (2.25.1)
Requirement already satisfied: docutils<0.20,>=0.14 in /usr/lib/python3/dist-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (0.17.1)
Requirement already satisfied: alabaster<0.8,>=0.7 in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (0.7.12)
Requirement already satisfied: sphinxcontrib-applehelp in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (1.0.2)
Requirement already satisfied: imagesize in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (1.4.1)
Requirement already satisfied: sphinxcontrib-serializinghtml>=1.1.5 in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (1.1.5)
Requirement already satisfied: sphinxcontrib-htmlhelp>=2.0.0 in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (2.0.0)
Requirement already satisfied: sphinxcontrib-qthelp in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (1.0.3)
Requirement already satisfied: babel>=1.3 in /usr/lib/python3/dist-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (2.8.0)
Requirement already satisfied: sphinxcontrib-devhelp in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (1.0.2)
Requirement already satisfied: Jinja2>=2.3 in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (3.1.2)
Requirement already satisfied: snowballstemmer>=1.1 in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (2.2.0)
Requirement already satisfied: sphinxcontrib-jsmath in ./.local/lib/python3.10/site-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (1.0.1)
Requirement already satisfied: Pygments>=2.0 in /usr/lib/python3/dist-packages (from Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (2.11.2)
Requirement already satisfied: MarkupSafe>=2.0 in ./.local/lib/python3.10/site-packages (from Jinja2>=2.3->Sphinx>=1.6->sphinxnotes-lilypond==1.5.1) (2.1.1)
$

$ make html
Running Sphinx v5.1.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 60 source files that are out of date
updating environment: [new config] 60 added, 0 changed, 0 removed
/home/kjcole/.local/lib/python3.10/site-packages/sphinx/directives/patches.py:87: RemovedInSphinx60Warning: RSTTable is deprecated.
  warnings.warn('RSTTable is deprecated.',
reading sources... [100%] welsh/index                                                        
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/kjcole/gits/websites/pages.codeberg.org/celtic_song_book/source/breton/back_page_en.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] welsh/index                                                         
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 1 warning.

The HTML pages are in build/html.

@kjcole
Copy link
Author

kjcole commented Aug 16, 2022

I've attached the actual SVG generated from the above here:
heather

@SilverRainZ
Copy link
Member

This is so weird, this issue should be fixed exactly :'(

@kjcole
Copy link
Author

kjcole commented Aug 16, 2022

Well, thanks for trying. I'm not in a hurry, and I'm thinking about work-arounds.

For example, with The Hundred Pipers, I commented out the additional verses from the LilyPond file and put them in the reStructuredText file. That made the generated PNG much smaller, an so the plugin didn't complain. (I'd still prefer to have the lyrics stay with the LilyPond file, but the solution works okay for now.)

@SilverRainZ
Copy link
Member

SilverRainZ commented Jul 30, 2023

I will drop ImageMagick (#32) in the 2.0, then this problem should be fixed (again Q_Q).

@SilverRainZ SilverRainZ added this to the 2.0 milestone Aug 5, 2023
@SilverRainZ
Copy link
Member

Hi @kjcole, can you please try again with 2.0.0 when you are free? so I can close this issue :D

@kjcole
Copy link
Author

kjcole commented Aug 19, 2023

What's the best way to install locally? I tried make and it gave errors:

$ make
make -C docs/
make[1]: Entering directory '~/.../lilypond/docs'
Running Sphinx v5.3.0

Configuration error:
There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "~/.local/lib/python3.10/site-packages/sphinx/config.py", line 350, in eval_config_file
    exec(code, namespace)
  File "~/.../lilypond/docs/conf.py", line 78, in <module>
    from sphinxnotes.any import Schema, Field as F
ModuleNotFoundError: No module named 'sphinxnotes.any'

make[1]: *** [Makefile:23: html] Error 2
make[1]: Leaving directory '~/.../lilypond/docs'
make: *** [Makefile:12: docs] Error 2

@SilverRainZ
Copy link
Member

Just use pip install sphinxnotes-lilypond==2.0.0.

@kjcole
Copy link
Author

kjcole commented Aug 19, 2023

$ pip3 install --user sphinxnotes-lilypond==2.0.0
ERROR: Could not find a version that satisfies the requirement sphinxnotes-lilypond==2.0.0 (from versions: 1.0a0, 1.0a1, 1.0a2, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.5.1, 1.6.0, 1.6.1, 2.0.0a1, 2.0.0a2, 2.0.0a3, 2.0.0a4)
ERROR: No matching distribution found for sphinxnotes-lilypond==2.0.0

@SilverRainZ
Copy link
Member

Ohh, so sorry, I forgot to push it PyPI. Please wait a minute and I will do that.

@SilverRainZ
Copy link
Member

You can try 2.0.1 now.

@SilverRainZ
Copy link
Member

And there are some breaking changes, you no longer need write a lot of options. for example:

1.x:

.. lilyinclude:: ./hundred_pipers.ly
   :nofooter:
   :noedge:
   :audio:
   :controls: top

2.x:

.. lilyinclude:: ./hundred_pipers.ly
   :controls: top

@kjcole
Copy link
Author

kjcole commented Aug 22, 2023

It appears to be working now. Thanks.

@kjcole kjcole closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants