https://bugs.kde.org/show_bug.cgi?id=359932

Milan Hauth <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #25 from Milan Hauth <[email protected]> ---
i have found a possible minimal reproducer for this bug:
https://github.com/milahu/okular-epub-reader-bug-cpuburn-css-short-fractional-sizes/blob/main/epub_bisect.15.py

all pathological EPUB files have these properties:

- external CSS stylesheet (stored in a separate .css file, not inlined in
.xhtml files)
- a CSS class with a size value with "leading zero omission", for example
`font-size: .5em` instead of `font-size: 0.5em`
- many HTML elements using that CSS class

as soon as the number of HTML elements hits some threshold
okular's CPU load explodes to infinite
(non-linear increase of complexity)

some example numbers are documented in the comments

the "good" number is the number of HTML elements
where the CPU load is still low

the "bad" number is the number of HTML elements
where the CPU load explodes to infinite

in "extreme bad" cases like `font_size=".6666em"`
the characters of the EPUB text are rendered as squares
so these cases seem to hit another threshold

```
test_synthetic_epubs(
    output_dir="synthetic-tests",
    epub_reader=epub_reader,

    # good: CPU load is low
    # bad: CPU load explodes to 100%
    # font_size=".1em", # bad: bracket: GOOD=272610, BAD=272611
    # font_size=".2em", # bad: bracket: GOOD=209700, BAD=209701
    # font_size=".3em", # bad: bracket: GOOD=157275, BAD=157276
    # font_size=".4em", # bad: bracket: GOOD=120578, BAD=120579
    # font_size=".5em", # bad: bracket: GOOD=94365, BAD=94366
    # font_size=".6em", # bad: bracket: GOOD=83880, BAD=83881
    # font_size=".7em", # bad: bracket: GOOD=73395, BAD=73396
    # font_size=".8em", # bad: bracket: GOOD=31954, BAD=31955
    # font_size=".9em", # bad: bracket: GOOD=31495, BAD=31496
    # font_size=".10em", # bad: bracket: GOOD=26217, BAD=26218
    # font_size=".11em", # bad: bracket: GOOD=26212, BAD=26213
    font_size=".12em", # bad: bracket: GOOD=20970, BAD=20971
    # font_size=".55em", # bad: bracket: GOOD=1053, BAD=1054
    # font_size=".85em", # bad: bracket: GOOD=612, BAD=613
    # font_size=".99em", # bad: bracket: GOOD=526, BAD=527
    # font_size=".88em", # bad: bracket: GOOD=591, BAD=592
    # font_size=".66em", # bad: bracket: GOOD=785, BAD=786
    # font_size=".777em", # bad: bracket: GOOD=72, BAD=73
    # font_size=".666em", # bad: bracket: GOOD=84, BAD=85

    # bad: characters are rendered as squares
    # font_size=".6666em", # bad
    # font_size=".7777em", # bad
    # font_size=".77777em", # bad
)
```

todo: write an epub-cleaner.py script to remove all "leading zero omission" CSS
sizes in an EPUB file
to make the EPUB file backward-compatible with old EPUB readers

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to