Bug 303217 - Cannot preview TIFF files on Mac OS due to "not enough memory" exceptions
Summary: Cannot preview TIFF files on Mac OS due to "not enough memory" exceptions
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Preview-Image (show other bugs)
Version: 2.6.0
Platform: MacPorts macOS
: NOR major
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-08 23:33 UTC by khisatomi
Modified: 2013-02-22 13:16 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description khisatomi 2012-07-08 23:33:31 UTC
Digikam does not preview large TIFF files in MacOS because of lack of enough memory. It is difficult to define a threshold because it fails with scanned images (Epson Photo Perfection hardware) of about 30MB but works with files of 55MB. Nevertheless, it always fails with files about 90MB of size.

OS X console output shows:

Jul  8 20:27:52 macbook [0x0-0x1d01d].digikam[221]: digikam(221)/digikam (core): Not enough memory to allocate buffer of size 147021488 
Jul  8 20:27:52 macbook [0x0-0x1d01d].digikam[221]: digikam(221)/digikam (core) Digikam::PreviewLoadingTask::execute: Cannot extract preview for  "/Users//img127.tif" 
Jul  8 20:27:53 macbook [0x0-0x1d01d].digikam[221]: digikam(221)/digikam (core): Not enough memory to allocate buffer of size 135233008 
Jul  8 20:27:53 macbook [0x0-0x1d01d].digikam[221]: digikam(221)/digikam (core) Digikam::PreviewLoadingTask::execute: Cannot extract preview for  "/Users/img126.tif" 

Reproducible: Always

Steps to Reproduce:
1. Go to an album with large TIFF files (about 90 MB always fails)
2. Digikam does not show any preview
3. Try to open an image also fails.
Actual Results:  
No preview available.

Expected Results:  
Show the images preview.
Comment 1 caulier.gilles 2012-07-09 10:07:58 UTC
Can you share your tiff image to test in local ?

Gilles Caulier
Comment 2 khisatomi 2012-07-09 19:20:13 UTC
I can share one of the files with problem. But where should I uploads them? Can I attach directly to the bug entry? The files may be as large as 90MB.
Comment 3 caulier.gilles 2012-07-09 21:25:38 UTC
Please use a web share service. Bugzilla is limited to 1Mb of attachment
Comment 4 khisatomi 2012-07-09 23:58:49 UTC
File upload to:

http://www.2shared.com/photo/SlbRZJR8/img128.html?

Password: digikam
Comment 5 caulier.gilles 2012-07-10 09:22:20 UTC
File can be previewed properly under Linux... No memory allocation problem...
Comment 6 khisatomi 2012-07-10 13:34:58 UTC
Yes, the problem appears to be only in OS X.
Comment 7 khisatomi 2012-07-15 04:05:23 UTC
Version 2.7.0 still has the bug.
Comment 8 Mike Gutzschhahn 2012-07-25 08:45:10 UTC
It also occures on OpenSuse 12.1 with DK 2.7.
Comment 9 khisatomi 2013-01-27 19:48:46 UTC
I did some new tests now using the Digikam 2.9 version.

Converted a problematic TIFF file to PNG and RAW with no success either. However, when
converting to JPG, Digikam could show the image (thumbnail and larger image).

Notes:

- Conversion done using Photoshop.
- The converted JPG has only 8 bits per channel, while the original file has 16.

Therefore, one conclusion here is that the problem is not related to only TIFF files, but also PNG and RAW. Should we change the bug title?
Comment 10 caulier.gilles 2013-02-22 13:14:35 UTC
Git commit b29bbdfd46df01dccac6058a7a2860cd84026caa by Gilles Caulier.
Committed on 22/02/2013 at 14:07.
Pushed by cgilles into branch 'master'.

new behavor about KMemoryInfo:
Check if memory info from current platform is supported or not (for ex, MacOSX is not support)
If not, -1 is returned from memory parser. In this case, digiKam will try to continue to allocate memory. An error message is printed to the console as debug statement.
If yes, we try to check memory info. If an error occur, 0 is returned, else 1.

This will solve multiple issues from bugzilla about non show large images in preview or editor, if memory allocation to store decompressed pixels data is more than 100Mb
Related: bug 314260

M  +6    -6    libs/3rdparty/kmemoryinfo/kmemoryinfo.cpp
M  +5    -2    libs/3rdparty/kmemoryinfo/kmemoryinfo.h
M  +80   -44   libs/3rdparty/kmemoryinfo/kmemoryinfo_backend.cpp
M  +10   -3    libs/dimg/loaders/dimgloader.cpp
M  +15   -2    libs/dimg/loaders/dimgloader.h

http://commits.kde.org/digikam/b29bbdfd46df01dccac6058a7a2860cd84026caa