Bug 421559

Summary: HEIC: Failed to open the data source: Too many open files (errno = 24)
Product: [Applications] digikam Reporter: Andrius <aegoreev>
Component: Metadata-EngineAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles, metzpinguin
Priority: NOR    
Version: 7.0.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In: 7.0.0
Sentry Crash Report:

Description Andrius 2020-05-15 11:51:36 UTC
dk7rc win64 I just imported 8,925 of JPGs, HEICs and MOV files and now digikam
can't create thumbnails for many of them (looks like HEIC only because JPGs and MOVs seem to be fine) while Showfoto opens them without a problem. My import I mean simply adding files into a folder via Windows Explorer.

[15684] digikam.metaengine: Cannot load metadata from file C:/Users/user/Pictures/FamilyPictures/DCIM_2020-05-13/IMG_S2437.HEIC  (Error # 9 :  C:/Users/user/Pictures/FamilyPictures/DCIM_2020-05-13/IMG_S2437.HEIC: Failed to open the data source: Too many open files (errno = 24)
[15684] Error: Could not open source file.
[15684] digikam.dimg: "C:/Users/user/Pictures/FamilyPictures/DCIM_2020-05-13/IMG_S2437.HEIC" : Unknown image format !!!
[15684] digikam.general: Cannot extract preview for "C:/Users/user/Pictures/FamilyPictures/DCIM_2020-05-13/IMG_S2437.HEIC"
[8836] 13028 0000000000000000 ENTER: DllCanUnloadNow
Comment 1 Maik Qualmann 2020-05-15 14:23:19 UTC
Yes, I can reproduce the problem on Windows. I'm looking at Linux tonight to see if the open files are growing. The problem must also occur with the Beta2. It depends on how many HEIF files you open. It is not Exiv2 that the files do not close, but the HEIF Loader. I suspect that libheif does not close the files. We updated the libheif, but there were no changes in the File IO area.

Maik
Comment 2 Andrius 2020-05-15 14:27:37 UTC
(In reply to Maik Qualmann from comment #1)
> Yes, I can reproduce the problem on Windows. I'm looking at Linux tonight to
> see if the open files are growing. The problem must also occur with the
> Beta2. It depends on how many HEIF files you open. It is not Exiv2 that the
> files do not close, but the HEIF Loader. I suspect that libheif does not
> close the files. We updated the libheif, but there were no changes in the
> File IO area.
> 
> Maik

I switched back to beta2 and looks like it is working fine.
I have 3,639 HEIC files in the folder which caused that problem.

I also noticed that "open in file manager" wasn't working for the affected files either. It seems like digiKam simply wasn't able see them.
Comment 3 Maik Qualmann 2020-05-15 14:34:42 UTC
In a folder with around 200 HEIC files, try using F5 to create new thumbnails.

Maik
Comment 4 Maik Qualmann 2020-05-15 18:47:41 UTC
Git commit fbad9b49fe4d8f3a423a16910cb1e55a1a77de5a by Maik Qualmann.
Committed on 15/05/2020 at 18:45.
Pushed by mqualmann into branch 'master'.

release HeifContext at the end of loading
FIXED-IN: 7.0.0

M  +2    -1    NEWS
M  +13   -2    core/dplugins/dimg/heif/dimgheifloader_load.cpp

https://invent.kde.org/kde/digikam/commit/fbad9b49fe4d8f3a423a16910cb1e55a1a77de5a
Comment 5 Maik Qualmann 2020-05-15 19:13:50 UTC
Git commit 136e3b27d07e0e5ef0122f3034054fe08c09d12d by Maik Qualmann.
Committed on 15/05/2020 at 19:11.
Pushed by mqualmann into branch 'master'.

simplify the HeifContext fix

M  +6    -12   core/dplugins/dimg/heif/dimgheifloader_load.cpp

https://invent.kde.org/kde/digikam/commit/136e3b27d07e0e5ef0122f3034054fe08c09d12d