Open rocketraman opened 1 year ago
It appears as though this error is coming from ttfunk. It likely has to do with either an invalid font or a font which contains something that ttfunk is not anticipating. Either way, if it is an issue with ttfunk, there is little we can do about it in this project. It would need to be reported to ttfunk.
Can you tell us whether this happens when using a built-in theme, or only when using a custom theme with your own fonts?
the system automatically retried and successfully generated the output for the same inputs
Given that's the case, it may be that the amount of input is just too large for the amount of memory allocated to the JVM. This is not uncommon when generating PDFs since the process requires a large amount of memory. So we might just have to say that if you see an error like this, it's necessary to allocate more memory to the JVM. (It probably scales linearly with the size of the PDF being generated, and hence the input).
Can you tell us whether this happens when using a built-in theme, or only when using a custom theme with your own fonts?
It is a custom theme with my own fonts. Here is the configuration theme.yml
:
# https://docs.asciidoctor.org/pdf-converter/latest/theme/keys/
extends: default
font:
catalog:
merge: true
Roboto:
normal: roboto-normal.ttf
italic: roboto-italic.ttf
bold: roboto-bold.ttf
bold_italic: roboto-bold_italic.ttf
NotoSansSymbols2:
normal: notosans-symbols2-normal.ttf
italic: notosans-symbols2-normal.ttf
bold: notosans-symbols2-normal.ttf
bold_italic: notosans-symbols2-normal.ttf
fallbacks:
- NotoSansSymbols2
base:
font-color: #24262b
font-family: Roboto
font-size: 12
line-height-length: 17
line-height: $base-line-height-length / $base-font-size
vertical-spacing: $base-line-height-length
page:
margin: [$base_line_height_length * 4, 1in, 0.75in, 1in]
green:
font-color: #00A664
title-page:
title:
font-color: #00A664
subtitle:
font-color: #00A664
heading:
font-color: #333333
font-size: 17
font-style: bold
line-height: 1.2
margin-bottom: $vertical-spacing
h2:
font-color: #00A664
header:
height: $base_line_height_length * 3
border-color: #dddddd
border-width: 0.25
vertical-align: middle
image-vertical-align: middle
recto: &shared_header
right:
content: image:logo.png[pdfwidth=0.3in]
center:
content: '{document-title}: {document-subtitle}'
verso: *shared_header
footer:
columns: =100%
recto: &shared_footer
center:
content: '{page-number}'
verso: *shared_footer
Here is the calling code:
asciidoctor.convert(
adoc,
Options.builder()
.backend("pdf")
.headerFooter(true)
.attributes(
Attributes.builder()
.attribute(
"pdf-theme",
"uri:classloader:/my/package/render/pdf/theme.yml"
)
.attribute(
"pdf-fontsdir",
"uri:classloader:/my/package/render/pdf/fonts;GEM_FONTS_DIR"
)
.attribute("imagesdir", "uri:classloader:/my/package/render/pdf/")
.build()
)
.safe(SafeMode.UNSAFE)
.toStream(outputStream)
.build()
Given that's the case, it may be that the amount of input is just too large for the amount of memory allocated to the JVM.
That's possible. I've only seen the error happen in a memory-constrained container environment. The asciidoc is small (about 6.6k of text) which outputs to about 7 pages. However the logo is 66KB and the font TTFs total about 1.3 MB. The output PDFs are between 160 and 190 KB -- the particular one that failed was 171.6 KB.
These containers are at the moment allocated 1Gi of memory.
It could very well be the size of the font, since ttfunk has to go through an process all of the data in it in order to be able to use it.
I received this
StackOverflowError
from my JVM backend while doing PDF conversions. The error was not specific to the inputs -- the system automatically retried and successfully generated the output for the same inputs.I was not able to reproduce the problem either.
However, hopefully the exception will help with isolating the issue.