Bug 372650 - On OS X, when tagging multiple images metadata is not correctly written to some image files or sidecars.
Summary: On OS X, when tagging multiple images metadata is not correctly written to so...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Sidecar (show other bugs)
Version: 5.4.0
Platform: macOS (DMG) macOS
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-19 00:37 UTC by Philip Tuckey
Modified: 2019-01-05 09:57 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 6.0.0


Attachments
Console log showing metadata writing to image files. (138.01 KB, text/plain)
2016-12-30 08:48 UTC, Philip Tuckey
Details
The original test image. (7.24 KB, image/jpeg)
2016-12-30 08:52 UTC, Philip Tuckey
Details
image0.jpg - shows incomplete metadata (7.32 KB, image/jpeg)
2016-12-30 08:53 UTC, Philip Tuckey
Details
image1.jpg - shows complete metadata (8.34 KB, image/jpeg)
2016-12-30 08:54 UTC, Philip Tuckey
Details
Console log showing metadata writing to sidecars. (138.61 KB, text/plain)
2016-12-30 08:57 UTC, Philip Tuckey
Details
image12.jpg.xmp - shows a truncated sidecar (54 bytes, application/vnd.xmind.media-package)
2016-12-30 09:01 UTC, Philip Tuckey
Details
image0.jpg.xmp - example of a complete sidecar (1.58 KB, application/vnd.xmind.media-package)
2016-12-30 09:02 UTC, Philip Tuckey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Tuckey 2016-11-19 00:37:55 UTC
Digikam is configured to write to sidecars only.
Select multiple images, e.g. about 100.
Apply the same tag to all of them, using the Captions pane.
For most images the sidecars are updated correctly, but for a few of them the sidecars are truncated to just their first line. This affects a different subset of files each time a tag is applied, apparently at random.
The console output shows most sidecars being written without error messages, while for the few files concerned it shows:

digikam.metaengine: Exiv2 ( 3 ) :  XMP Toolkit error 101: Unregistered schema namespace URI
digikam.metaengine: Exiv2 ( 3 ) :  Failed to encode XMP metadata.

This behaviour happens on OS X.
Running under linux (ubuntu) in a virtual machine I do NOT see the same problem.
Comment 1 Philip Tuckey 2016-12-09 00:28:07 UTC
This problem also occurs when writing metadata to the image files. To test this, I changed the digikam preferences to not use sidecars. The test images are jpegs and I am writing just one tag to them, "print". The console shows a few error messages the same as in the initial report, and for a few files the metadata is NOT written. Again, this is running on OS X, updated to Sierra (the initial report was under El Capitan).
Comment 2 caulier.gilles 2016-12-09 03:55:19 UTC
I build a new version of OSX installer for next release 5.4.0, using Exiv2 shared lib 0.26-svn not yet released, but including more than 200 bugfixes. It will be interesting to see if this file still reproducible.

The OSX installer is available here :

https://drive.google.com/drive/folders/0BzeiVr-byqt5Y0tIRWVWelRJenM

Gilles Caulier
Comment 3 Philip Tuckey 2016-12-27 22:12:19 UTC
Thank you for doing that Gilles. I have tested the new version and the behaviour is the same: occasional errors in writing metadata to image files or sidecars, when updating many images at once. (I updated the bug title and component to be more precise.)
Another way to trigger the problem is "Album->Write Metadata to Images", which is consistent since it rewrites the metadata of all images, and unfortunate as one wants to use this menu item to clean up the metadata.
This does not seem to be a "straightforward" bug in Exiv2, as the problem does not occur under linux, it is specific to OS X. The apparently random occurrence may suggest some kind of overflow error. Is the bug necessarily in Exiv2, could it be in digikam?
Comment 4 caulier.gilles 2016-12-27 22:24:09 UTC
This is a good question. 

The DK implementation is a high level wrapper to preapre metadata to write a good place. It's Qt code, mostly portable as well..

Al low level operations are managed at end by Exiv2. If the problem become on access to files, well, this can be an Exiv2 dysfunction.

To investiguate, if you are able to reproduce the problem easily, is to run DK from a console. The binary is :

/opt/digikam/Applications/KF5/digikam.app/Contents/MacOS/digikam

Just run it and catch all the debug statements printed on the console when problem occurs.

Gilles Caulier
Comment 5 Philip Tuckey 2016-12-28 07:48:42 UTC
I gave the console error messages in the initial description, but I will upload a full console log asap. It seems to me that those error messages don't tell us whether the problem is a bug in Exiv2, or if digikam is providing bad data to Exiv2 (only occasionally of course). We would need digikam to print out the data each time it calls Exiv2.
Comment 6 Philip Tuckey 2016-12-30 08:41:26 UTC
I have run a couple of examples using 100 copies of the same jpg image, i.e.
$ for i in {0..99}; do cp image.jpg test/image$i.jpg; done
I will upload relevant files following this message.
Comment 7 Philip Tuckey 2016-12-30 08:48:42 UTC
Created attachment 103079 [details]
Console log showing metadata writing to image files.
Comment 8 Philip Tuckey 2016-12-30 08:51:59 UTC
During that run, metadata was not correctly written to 7 images: image0.jpg, 3, 9, 12, 26, 38, 87. All others were written correctly.
Comment 9 Philip Tuckey 2016-12-30 08:52:46 UTC
Created attachment 103080 [details]
The original test image.
Comment 10 Philip Tuckey 2016-12-30 08:53:39 UTC
Created attachment 103081 [details]
image0.jpg - shows incomplete metadata
Comment 11 Philip Tuckey 2016-12-30 08:54:21 UTC
Created attachment 103082 [details]
image1.jpg - shows complete metadata
Comment 12 Philip Tuckey 2016-12-30 08:57:07 UTC
Created attachment 103083 [details]
Console log showing metadata writing to sidecars.

During this run, the sidecars for 5 images were truncated: image12.jpg, 24, 36, 76, 81. All the other sidecars were correctly written (as far as I can tell).
Comment 13 Philip Tuckey 2016-12-30 09:01:22 UTC
Created attachment 103084 [details]
image12.jpg.xmp - shows a truncated sidecar
Comment 14 Philip Tuckey 2016-12-30 09:02:25 UTC
Created attachment 103086 [details]
image0.jpg.xmp - example of a complete sidecar
Comment 15 caulier.gilles 2016-12-30 09:47:06 UTC
Did you set a configuration to write comment to ACDSEE XMP namespace ?

digikam.metaengine: Will write Metadata to file "/Users/test/Pictures/test/image0.jpg"
digikam.metaengine: xmlACDSee "<Categories><Category Assigned=\"1\">blabla</Category></Categories>"
digikam.general: -------------------------- New Keywords ("blabla")

Gilles
Comment 16 Philip Tuckey 2016-12-30 19:05:12 UTC
Not to my knowledge. I set up a test account and started up digikam with a
Comment 17 Philip Tuckey 2016-12-30 19:06:29 UTC
Not to my knowledge. I set up a test account and started up digikam with a clean config, just changing the image/sidecar metadata settings.
Comment 18 Philip Tuckey 2016-12-30 19:16:14 UTC
I just did a test by starting up digikam without a digikamrc file and accepting the default setup options. By default metadata writing is deactivated, but all the options on the metadata->Advanced tab are selected (so they become active when metadata writing is turned on).
Comment 19 Philip Tuckey 2018-12-12 17:27:42 UTC
Dear Gilles, Maik and other maintainers
I'm very very very pleased to report that 
digiKam-6.0.0-beta3-20181208T124813-MacOS-x86-64.pkg
does not display this Mac-specific metadata-writing bug.
It was present in all previous versions I tested up to 6.0.0-beta2 of 15th October.
(I did not test any build of beta3 before 8th Dec.)
Could you please comment on whether this is due to a fix or to chance? Are you aware of a change in code or in the MacOS build process between beta2 15 Oct and beta3 8 Dec which may have affected this behaviour?
Thanks very much
Philip
Comment 20 caulier.gilles 2019-01-05 09:57:49 UTC
Thanks for your feedback. I close this file now...

Gilles Caulier