Bug 273402 - JPG2000 image makes kio_thumbnail hog the CPU forever
Summary: JPG2000 image makes kio_thumbnail hog the CPU forever
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kimgio (show other bugs)
Version: 4.8.4
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Christoph Feck
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-16 11:10 UTC by S. Burmeister
Modified: 2012-10-25 23:01 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.3
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description S. Burmeister 2011-05-16 11:10:41 UTC
Version:           unspecified (using KDE 4.6.2) 
OS:                Linux

If one hovers a JPG2000 image in e.g. dolphin with the information panel open kio_thumbnail will start to consume a lot of CPU and never stop doing so.

To reproduce: Use digikam to save a picture as JPG2000, open dolphin and hover the file.

It seems Gwenview is affected by the same issue since it also starts to use a lot of CPU while trying to generate a thumbnail. To try that simply open an image with gwenview from the folder where the JPG2000 is in and watch gwenview trying to generate the thumbnail for its preview pane.

Reproducible: Always
Comment 1 Christoph Feck 2011-05-16 12:01:04 UTC
KDE uses JasPer library to load JPEG 2000 image, so you should report the problem to JasPer developers at http://en.wikipedia.org/wiki/JasPer

This library is very slow to begin with. A similar (but incompatible) PGF format can be loaded about 10 times faster, according to its designers, see http://www.libpgf.org/

There is, however, possible room for optimization in the thumbnail loader. It could load a smaller resolution, instead of the full image, similar to what the JPEG loader does.

I have yet to investigate if we need a special JPEG 2000 thumbnailer, or if changes in kimgio loader are sufficient.
Comment 2 S. Burmeister 2011-05-16 12:13:35 UTC
There are no previews available for PGF in KDE, see bug 273351.

Is libjasper really that slow that it takes one whole CPU for > 10 minutes to generate a thumbnail from a picture with the filesize of ~7 MB?
Comment 3 Christoph Feck 2011-05-16 15:53:57 UTC
How large is that image? The file size is not really that significant, but image dimensions are. Since JPEG 2000 processes images both horizontally and vertically, you get millions of cache misses/flushes when processing large images.

Can you install not only the JasPer library, but also its accompanying command line tools, and convert that file to (say) PNM format and compare the timings?

The command is:

    jasper -t jp2 -f inputimage.jp2 -T pnm -F outputimage.pnm
Comment 4 S. Burmeister 2011-06-05 12:01:43 UTC
Ok. I tried the command above and it takes ~9 seconds to convert the image. Its dimensions are 2736x3648 pixel. Creating a thumbnail with kio_thumbnail takes a lot longer measured from its time of high cpu usage before it displays the thumbnail. kio_thumbnail takes > 2 minutes when I hover the picture in dolphin.
Comment 5 Nico Dorn 2012-07-26 10:18:26 UTC
Confirmed for KDE 4.8.4 on Kubuntu (but the problem exists much longer, as it is said above).
Comment 6 Christoph Feck 2012-10-25 01:58:36 UTC
Git commit e96bd5e148ba163137bf0dbefd2c41652c0fb8d1 by Christoph Feck.
Committed on 25/10/2012 at 03:52.
Pushed by cfeck into branch 'KDE/4.9'.

Fix performance issue with JPEG-2000 loader

Instead of reading each component value individually,
convert complete rows to a temporary matrix, and fetch
the values from there.

Additionally, make sure the QImage allocation succeeds.
FIXED-IN: KDE 4.9.3

M  +30   -3    kimgio/jp2.cpp

http://commits.kde.org/kdelibs/e96bd5e148ba163137bf0dbefd2c41652c0fb8d1