Bug 424691

Summary: Thumbnails not showing for face tags [patch]
Product: [Applications] digikam Reporter: LarsE <ristretto17>
Component: Faces-WorkflowAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles, metzpinguin, spam-receiver
Priority: NOR    
Version: 7.0.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In: 7.2.0
Sentry Crash Report:
Attachments: screenshot of missing thumbnails
extended log showing database access error
attachment-7442-0.html
useTagsTreeV1.patch
useTagsTreeV2.patch
useTagsTreeV3.patch

Description LarsE 2020-07-26 17:13:47 UTC
Created attachment 130411 [details]
screenshot of missing thumbnails

SUMMARY. 
Thumbnails are not shown for People tags.

STEPS TO REPRODUCE
1. I started face recognition from scratch with digikam 7. I.e. I removed all existing face tags and used the database maintenance tool to clean all face tags.
2. Then I started the process with one person. I let digikam detect faces on three example pictures (a portrait just showing this one person) and put a freshly created face tag "People/M." on each of the detected faces on those three pictures.
3. Then I started the face recognition process on the rest of the 41 pictures in the same album. All pictures were added to the already existing "M." tag or to the "Unknown" tag. 
4. To review the results, I switched to the "people" area. There I found, that no thumbnail is shown neither for pictures assigned to the "M." nor for the pictures assigned to the "Unknown" tag.


OBSERVED RESULT
No thumbnails are shown for the People tag view

EXPECTED RESULT
Show the thumbnails ;-)

SOFTWARE/OS VERSIONS
Windows: 10 professional x64 (1909)
Qt Version: 5.14.2

ADDITIONAL INFORMATION
Database running on mariaDB 10.5.4
Double-checked on two different machines (same OS, but different graphic cards) with the same result.
Comment 1 Maik Qualmann 2020-07-26 20:39:49 UTC
I remember a bug report in which 2 graphics cards were in the computer and one was setup in the Windows settings for acceleration. Then no thumbnails were drawn, just like your frame is missing, etc. I look for the bug report. Otherwise this problem is unknown.

Maik
Comment 2 Maik Qualmann 2020-07-26 20:41:43 UTC
It could be the same cause as in bug 416183.

Maik
Comment 3 Maik Qualmann 2020-07-26 21:02:47 UTC
Download and start DebugView from Microsoft. Start digiKam and open the People view. Post the messages in DebugView.

Maik
Comment 4 LarsE 2020-07-27 05:53:40 UTC
Thanks for your quick reply - here comes the output of DebugView after starting digikam: 

>>>>>>>>>>>>>>>>>>>>>
[2404] QCommandLineParser: already having an option named "?"
[2404] QCommandLineParser: already having an option named "help-all"
[2404] QCommandLineParser: already having an option named "v"
[2404] KMemoryInfo: Platform identified :  "WINDOWS"
[2404] KMemoryInfo: TotalRam:  7971938304
[2404] MaterialIcons cannot be loaded !
[2404] kf5.kxmlgui: Unhandled container to remove :  Digikam::DigikamApp
[2404] digikam.general: Failed to list url:  ""
[2404] QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout
>>>>>>>>>>>>>>>>>>>>>

With every click on a People-Tag folder, the following message-pair will be added to the message stack:
digikam.general: Failed to list url:  ""
QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout

For both systems, it's the same output sequence. 

Both computers have two built-in graphic cards: 
- Intel HD Graphics 530 + NVIDIA GeForce 940MX (system 1) and 
- Intel HD Graphics 3000 + NVIDIA Quadro 1000M (system 2). 
On both systems, it makes no difference, if pushing the digikam application to the NVIDIA GPU or to the INTEL GPU. The effect remains the same.
Comment 5 Maik Qualmann 2020-07-27 06:10:41 UTC
Here is a "Failed to list url:" problem.
Activate the debug output by setting an environment variable in the Windows environment editor.

Variable:
QT_LOGGING_RULES

Value:
digikam.*=true

Now post the full messages, I suspect a problem with the database.

Maik
Comment 6 LarsE 2020-07-28 05:31:19 UTC
Created attachment 130450 [details]
extended log showing database access error
Comment 7 LarsE 2020-07-28 05:34:29 UTC
You were right, it seems to be a database related issue - some access error is shown in the log. Please refer to the attached file. 
I'm not sure, which access rights might be missing, since the mentioned user has all rights and grants on the digikam* databases. 
Side note: from my perception all other features (fetch pictures with a distinct tag, photos inside a certain time-line, etc.) work as expected.
Comment 8 Maik Qualmann 2020-07-28 05:50:00 UTC
The error message is clear, you have missing rights to the database.

----------------
Error messages: "QMYSQL: Unable to execute query" "Access denied for user 'digikam'@'192.168.178.__' (using password: YES)" "1045" 2
----------------

Did you observe the requirements tab in the digiKam database settings?
You have set "mariadb" as hostname. Setting access rights to may help:

GRANT ALL PRIVILEGES ON digikam.* TO 'digikam'@'mariadb';

Maik
Comment 9 Maik Qualmann 2020-07-29 17:58:26 UTC
Could the rights problem on the database table be solved?

Maik
Comment 10 LarsE 2020-07-30 21:12:21 UTC
Hi Maik,

today I had some time to do some more testing. Please see the results below. 

I think it's important to put some more information in advance to allow for a better understanding of my set-up: 
- I'm working on a computer "X" with digikam
- the database runs on a different computer "mariadb"
Therefore I initially set up a user "digikam@192.168.178.__" in the mariadb server with all rights activated for all digikam* databases. Doing so, I wanted to grant users from a certain set of systems in the network access to the digikam databases.

This in mind, I now tested some user configurations: 


digikam@mariadb
===============
Doesn't work at all. Starting digikam results in a no access to the database error and that's clear to me, since computer "X" connecting to the mariaDB server is not computer "mariadb".


digikam@192.168.178.__
======================
Activated all rights on all digikam* databases.
This works fine for accessing the database normally (setting and filtering tags, viewing the photo thumbnails, etc.), but not for the faces feature. When changing to the People tab in digikam, we get the already known error:

[16120] Error messages: "QMYSQL: Unable to execute query" "Access denied for user 'digikam'@'192.168.178.__' (using password: YES)" "1045" 2 

Now I added also all global rights to this user, resulting in the following message, when trying to access the People view in digikam:
[11068] Error messages: "QMYSQL: Unable to execute query" "The user specified as a definer ('digikam'@'%') does not exist" "1449" 2 


digikam@%
=========
Setting all rights on all digikam* databases, no global rights.
-> This user now works also for the People tab.


Does this make sense to you? Seems as if different users are called by digikam when working on the database? If it would be necessary to add a user "digikam@%", this from my point of view would be not very nice with respect to access control. You can't restrict systems in the network from connecting to the digikam* databases.

Cheers,
Lars.
Comment 11 Maik Qualmann 2020-07-31 13:43:18 UTC
I took a closer look at your error message:

IN (SELECT id FROM TagsTree WHERE pid=1272)

There are no TagsTree in a MySQL / MariaDB database!
The TagsTree is only available in an SQLite database. How did you create the MariaDB? Copied from SQLite? That does not work. To switch from SQLite to MySQL you have to use the migration tool built into digiKam.

Maik
Comment 12 LarsE 2020-07-31 19:12:51 UTC
Thanks for looking deeper into this. I always used the mySQL mariaDB database, when I started with digikam some time ago. I set up an empty database and let digikam go and index all photos of my collection. So I have no idea, where this structure might come from. What would you suggest to do without loosing information?

And what do you think about the issue regarding the digikam@% user required?
Comment 13 Maik Qualmann 2020-07-31 19:57:39 UTC
Please deactivate View-> Include Tag Sub-Tree
Does it work now?

Maik
Comment 14 Maik Qualmann 2020-07-31 20:45:38 UTC
OK, the problem is now clear to me, also why it occurs and not for me, I fix it.

Maik
Comment 15 Maik Qualmann 2020-08-01 05:04:17 UTC
Git commit 2189f7c1bbea606fea9784d37adb344df3c2038a by Maik Qualmann.
Committed on 01/08/2020 at 05:00.
Pushed by mqualmann into branch 'master'.

fix SQL query for MySQL in recursive Tags search
FIXED-IN: 7.1.0

M  +2    -3    NEWS
M  +12   -1    core/libs/database/item/query/itemquerybuilder.cpp
M  +2    -0    core/libs/database/item/query/itemquerybuilder_p.h

https://invent.kde.org/graphics/digikam/commit/2189f7c1bbea606fea9784d37adb344df3c2038a
Comment 16 LarsE 2020-08-01 15:33:11 UTC
Created attachment 130556 [details]
attachment-7442-0.html

Hi Maik,
Thanks for your support, deactivating in View works like a charm also with the digikam@192.168.178.__ user.
Bye,
Lars.
________________________________
From: Maik Qualmann <bugzilla_noreply@kde.org>
Sent: Saturday, August 1, 2020 7:04:17 AM
To: ristretto17@live.com <ristretto17@live.com>
Subject: [digikam] [Bug 424691] Thumbnails not showing for face tags

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

Maik Qualmann <metzpinguin@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
      Latest Commit|                            |https://invent.kde.org/grap
                   |                            |hics/digikam/commit/2189f7c
                   |                            |1bbea606fea9784d37adb344df3
                   |                            |c2038a
   Version Fixed In|                            |7.1.0
             Status|CONFIRMED                   |RESOLVED

--- Comment #15 from Maik Qualmann <metzpinguin@gmail.com> ---
Git commit 2189f7c1bbea606fea9784d37adb344df3c2038a by Maik Qualmann.
Committed on 01/08/2020 at 05:00.
Pushed by mqualmann into branch 'master'.

fix SQL query for MySQL in recursive Tags search
FIXED-IN: 7.1.0

M  +2    -3    NEWS
M  +12   -1    core/libs/database/item/query/itemquerybuilder.cpp
M  +2    -0    core/libs/database/item/query/itemquerybuilder_p.h

https://invent.kde.org/graphics/digikam/commit/2189f7c1bbea606fea9784d37adb344df3c2038a

--
You are receiving this mail because:
You reported the bug.
Comment 17 Maik Qualmann 2020-08-07 09:58:34 UTC
*** Bug 425100 has been marked as a duplicate of this bug. ***
Comment 18 Maik Qualmann 2020-08-09 10:08:52 UTC
Git commit 71194e35cbfbd107a9f7df0dcc1339bbe9a7b99f by Maik Qualmann.
Committed on 09/08/2020 at 10:08.
Pushed by mqualmann into branch 'master'.

revert "fix SQL query for MySQL in recursive Tags search"

M  +1    -12   core/libs/database/item/query/itemquerybuilder.cpp
M  +0    -2    core/libs/database/item/query/itemquerybuilder_p.h

https://invent.kde.org/graphics/digikam/commit/71194e35cbfbd107a9f7df0dcc1339bbe9a7b99f
Comment 19 Maik Qualmann 2020-08-09 10:16:48 UTC
The "TagsTree" table is a VIEW table under MySQL. The main cause of this problem is that the user of the database probably does not have the SHOW VIEW and CREATE VIEW privileges. If you have not assigned all the privileges, these must be added separately. Since this problem also affects other SQL queries, the privileges must be set correctly.

Maik
Comment 20 LarsE 2020-08-09 12:53:56 UTC
Hi Maik,

thanks for further investigating this issue. 

This is somehow strange -> please have a look at my comments 7 and 10: the database user "digikam" already has all rights and all grants assigned (including "SHOW VIEW" and "CREATE VIEW"). From the log-file it was clear to me, that you use a view here. Therefore I already double-checked the database user access rights on server side. 

From comment 10 you may also see, that with **activated** option "View/Include Tag Sub-Tree" just when the user "digikam@%" exists (with exactly the same rights assigned as the user "digikam@192.168.178.__" before, i.e. all rights on all digikam* databases, no global rights), the operation succeeds. 

If just the user "digikam@192.168.178.__" is available (this time also with all global rights activated), there was a message indicating, that the user "digikam@%" that created the view is not available in the database. Therefore I had the assumption, that different users are used for creating and accessing the view.

Perhaps this points into the right direction to fix this issue?

Bye, 
Lars.
Comment 21 Maik Qualmann 2020-08-12 11:42:12 UTC
Why the problem is currently triggered (we have 2 users who it affects) with a table of VIEW, I cannot say at the moment. The code on our side has not changed in years. It has never been reported as a problem before. I suspect a change or bug in MariaDB. I cannot reproduce the problem here. However, we plan to convert the TagsTree VIEW to a table, just like in SQLite. However, this will not be done before digiKam-7.2.0. I'll post the first patch soon.

Maik
Comment 22 Maik Qualmann 2020-08-12 20:30:08 UTC
Created attachment 130834 [details]
useTagsTreeV1.patch

First version to switch to the TagsTree table under MySQL.

Maik
Comment 23 Maik Qualmann 2020-08-13 06:07:28 UTC
Created attachment 130839 [details]
useTagsTreeV2.patch

Fix database migration.

Maik
Comment 24 Maik Qualmann 2020-10-16 05:54:00 UTC
Created attachment 132403 [details]
useTagsTreeV3.patch

Updated to git/master.

Maik
Comment 25 Maik Qualmann 2020-10-16 08:49:53 UTC
@Gilles, I plan to apply the patch. It's a major change for MySQL, but SQLite is unchanged. With Beta 2 and 3 we have time to fix if problems arise.

Maik
Comment 26 caulier.gilles 2020-10-16 09:08:46 UTC
Hi Maik,

Yes, i delayed the beta1 to at least integrate the fix about face scan crash.

Do you want to release beta1 while this week end or wait again a little bit ?

Gilles
Comment 27 Maik Qualmann 2020-10-16 10:42:32 UTC
Git commit e8e2ab5f0bd3bc533b6c6c23c16f2fc3095f7c2e by Maik Qualmann.
Committed on 16/10/2020 at 10:40.
Pushed by mqualmann into branch 'master'.

switch under MySQL to a TagsTree table with triggers
FIXED-IN: 7.2.0

M  +3    -1    NEWS
M  +156  -143  core/data/database/dbconfig.xml.cmake.in
M  +2    -19   core/libs/database/coredb/coredb.cpp
M  +4    -1    core/libs/database/coredb/coredbschemaupdater.cpp

https://invent.kde.org/graphics/digikam/commit/e8e2ab5f0bd3bc533b6c6c23c16f2fc3095f7c2e
Comment 28 Maik Qualmann 2020-10-16 16:33:52 UTC
For me this weekend is fine to release Beta1.

Maik
Comment 29 LarsE 2020-11-03 11:28:34 UTC
Hi Maik,

I just installed 7.2.0 beta-1 -> activated View / Include Tag-Subtree -> works. The faces thumbnails are shown also with this setting, now.

I appreciate your work on this issue - thanks and have a good time, 
bye,
Lars.