Photo Viewer not working

Nextcloud version : 19.0.3
Operating system and version : Freenas
Apache or nginx version : 2.4.46
PHP version : 7.4

Hi,
I’m having trouble viewing photos with nextcloud. If I click on an image in file section, it starts downloading the file instead of using the viewer function. And on the photo app, clicking on an image doesn’t do anything.
I’ve tried on occ check-core and check-app for the viewer app and nothing wrong it seems.

Is this the first time you’ve seen this error? : Yes

The output of your Nextcloud log in Admin > Logging:

Error	PHP	Version warning: Imagick was compiled against ImageMagick version 1690 but version 1691 is loaded. Imagick will run but may behave surprisingly at Unknown#0
Error	PHP	imagettftext(): Problem doing text layout at /usr/local/www/nextcloud/lib/private/Preview/TXT.php#92

Have you changed the installation? I do not know “Freenas”. But perhaps there is a conflict between the php-version and the imagemagick-version. On normal linux systems (Debian or Ubuntu) you install “php-imagick” https://packages.debian.org/buster/php-imagick

Read another thread about php-imagick:
Imagick missing - version php 7.3

Hi,

I didn’t change my installation other than upgrading from 18.X to 19.
Sorry, for the system I meant FreeBsd 11.3. I’ve already installed php-magick for the 7.4 php version. I’ve tried to reinstall it, but it didn’t work.

I’ve got some error on the admin logging (one for each user) also :

{"reqId":"3out8qXe939daziLEb44","level":3,"time":"2020-09-25T06:58:49+00:00","remoteAddr":"","user":"--","app":"files","method":"","url":"--","message":{"Exception":"Doctrine\\DBAL\\Exception\\DriverException","Message":"An exception occurred while executing 'SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)' with params [5, \"d41d8cd98f00b204e9800998ecf8427e\"]:\n\nSQLSTATE[HY000]: General error: 2006 MySQL server has gone away","Code":0,"Trace":[{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php","line":169,"function":"convertException","class":"Doctrine\\DBAL\\Driver\\AbstractMySQLDriver","type":"->","args":["An exception occurred while executing 'SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)' with params [5, \"d41d8cd98f00b204e9800998ecf8427e\"]:\n\nSQLSTATE[HY000]: General error: 2006 MySQL server has gone away",{"errorInfo":["HY000",2006,"MySQL server has gone away"],"__class__":"Doctrine\\DBAL\\Driver\\PDOException"}]},{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php","line":145,"function":"wrapException","class":"Doctrine\\DBAL\\DBALException","type":"::","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDOMySql\\Driver"},{"errorInfo":["HY000",2006,"MySQL server has gone away"],"__class__":"Doctrine\\DBAL\\Driver\\PDOException"},"An exception occurred while executing 'SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)' with params [5, \"d41d8cd98f00b204e9800998ecf8427e\"]:\n\nSQLSTATE[HY000]: General error: 2006 MySQL server has gone away"]},{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":911,"function":"driverExceptionDuringQuery","class":"Doctrine\\DBAL\\DBALException","type":"::","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDOMySql\\Driver"},{"errorInfo":["HY000",2006,"MySQL server has gone away"],"__class__":"Doctrine\\DBAL\\Driver\\PDOException"},"SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)",{"1":5,"2":"d41d8cd98f00b204e9800998ecf8427e"}]},{"file":"/usr/local/www/nextcloud/lib/private/DB/Connection.php","line":194,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)",[5,"d41d8cd98f00b204e9800998ecf8427e"],[1,2],null]},{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":200,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = :dcValue1) AND (`path_hash` = :dcValue2)",{"dcValue1":5,"dcValue2":"d41d8cd98f00b204e9800998ecf8427e"},{"dcValue1":1,"dcValue2":2}]},{"file":"/usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":216,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Cache/Cache.php","line":472,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Mount/MountPoint.php","line":272,"function":"getId","class":"OC\\Files\\Cache\\Cache","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Filesystem.php","line":440,"function":"getStorageRootId","class":"OC\\Files\\Mount\\MountPoint","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Filesystem.php","line":376,"function":"initMountPoints","class":"OC\\Files\\Filesystem","type":"::","args":["adrien"]},{"file":"/usr/local/www/nextcloud/lib/private/legacy/OC_Util.php","line":308,"function":"init","class":"OC\\Files\\Filesystem","type":"::","args":["adrien","/adrien/files"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":116,"function":"setupFS","class":"OC_Util","type":"::","args":["adrien"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":155,"function":"getMounts","class":"OC\\Files\\Utils\\Scanner","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/apps-pkg/files/lib/BackgroundJob/ScanFiles.php","line":83,"function":"backgroundScan","class":"OC\\Files\\Utils\\Scanner","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/apps-pkg/files/lib/BackgroundJob/ScanFiles.php","line":111,"function":"runScanner","class":"OCA\\Files\\BackgroundJob\\ScanFiles","type":"->","args":[{"__class__":"OC\\User\\User"}]},{"file":"/usr/local/www/nextcloud/lib/private/BackgroundJob/Job.php","line":62,"function":"run","class":"OCA\\Files\\BackgroundJob\\ScanFiles","type":"->","args":[null]},{"file":"/usr/local/www/nextcloud/lib/private/BackgroundJob/TimedJob.php","line":57,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]},{"file":"/usr/local/www/nextcloud/cron.php","line":126,"function":"execute","class":"OC\\BackgroundJob\\TimedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php","Line":106,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDOException","Message":"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away","Code":"HY000","Trace":[{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":903,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDOStatement","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/DB/Connection.php","line":194,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)",[5,"d41d8cd98f00b204e9800998ecf8427e"],[1,2],null]},{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":200,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = :dcValue1) AND (`path_hash` = :dcValue2)",{"dcValue1":5,"dcValue2":"d41d8cd98f00b204e9800998ecf8427e"},{"dcValue1":1,"dcValue2":2}]},{"file":"/usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":216,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Cache/Cache.php","line":472,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Mount/MountPoint.php","line":272,"function":"getId","class":"OC\\Files\\Cache\\Cache","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Filesystem.php","line":440,"function":"getStorageRootId","class":"OC\\Files\\Mount\\MountPoint","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Filesystem.php","line":376,"function":"initMountPoints","class":"OC\\Files\\Filesystem","type":"::","args":["adrien"]},{"file":"/usr/local/www/nextcloud/lib/private/legacy/OC_Util.php","line":308,"function":"init","class":"OC\\Files\\Filesystem","type":"::","args":["adrien","/adrien/files"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":116,"function":"setupFS","class":"OC_Util","type":"::","args":["adrien"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":155,"function":"getMounts","class":"OC\\Files\\Utils\\Scanner","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/apps-pkg/files/lib/BackgroundJob/ScanFiles.php","line":83,"function":"backgroundScan","class":"OC\\Files\\Utils\\Scanner","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/apps-pkg/files/lib/BackgroundJob/ScanFiles.php","line":111,"function":"runScanner","class":"OCA\\Files\\BackgroundJob\\ScanFiles","type":"->","args":[{"__class__":"OC\\User\\User"}]},{"file":"/usr/local/www/nextcloud/lib/private/BackgroundJob/Job.php","line":62,"function":"run","class":"OCA\\Files\\BackgroundJob\\ScanFiles","type":"->","args":[null]},{"file":"/usr/local/www/nextcloud/lib/private/BackgroundJob/TimedJob.php","line":57,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]},{"file":"/usr/local/www/nextcloud/cron.php","line":126,"function":"execute","class":"OC\\BackgroundJob\\TimedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","Line":119,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away","Code":"HY000","Trace":[{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","line":117,"function":"execute","class":"PDOStatement","type":"->","args":[null]},{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":903,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDOStatement","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/DB/Connection.php","line":194,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = ?) AND (`path_hash` = ?)",[5,"d41d8cd98f00b204e9800998ecf8427e"],[1,2],null]},{"file":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":200,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT `fileid` FROM `oc_filecache` WHERE (`storage` = :dcValue1) AND (`path_hash` = :dcValue2)",{"dcValue1":5,"dcValue2":"d41d8cd98f00b204e9800998ecf8427e"},{"dcValue1":1,"dcValue2":2}]},{"file":"/usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":216,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Cache/Cache.php","line":472,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Mount/MountPoint.php","line":272,"function":"getId","class":"OC\\Files\\Cache\\Cache","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Filesystem.php","line":440,"function":"getStorageRootId","class":"OC\\Files\\Mount\\MountPoint","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Filesystem.php","line":376,"function":"initMountPoints","class":"OC\\Files\\Filesystem","type":"::","args":["adrien"]},{"file":"/usr/local/www/nextcloud/lib/private/legacy/OC_Util.php","line":308,"function":"init","class":"OC\\Files\\Filesystem","type":"::","args":["adrien","/adrien/files"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":116,"function":"setupFS","class":"OC_Util","type":"::","args":["adrien"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":155,"function":"getMounts","class":"OC\\Files\\Utils\\Scanner","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/apps-pkg/files/lib/BackgroundJob/ScanFiles.php","line":83,"function":"backgroundScan","class":"OC\\Files\\Utils\\Scanner","type":"->","args":[""]},{"file":"/usr/local/www/nextcloud/apps-pkg/files/lib/BackgroundJob/ScanFiles.php","line":111,"function":"runScanner","class":"OCA\\Files\\BackgroundJob\\ScanFiles","type":"->","args":[{"__class__":"OC\\User\\User"}]},{"file":"/usr/local/www/nextcloud/lib/private/BackgroundJob/Job.php","line":62,"function":"run","class":"OCA\\Files\\BackgroundJob\\ScanFiles","type":"->","args":[null]},{"file":"/usr/local/www/nextcloud/lib/private/BackgroundJob/TimedJob.php","line":57,"function":"execute","class":"OC\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]},{"file":"/usr/local/www/nextcloud/cron.php","line":126,"function":"execute","class":"OC\\BackgroundJob\\TimedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"/usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","Line":117}},"CustomMessage":"--"},"userAgent":"--","version":"19.0.3.1","id":"5f6d9787d82a8"}

and some 404 error on the httpd-access.log whenever I click on an image from the photo app :

90.127.73.XX - - [25/Sep/2020:09:14:26 +0200] "GET /index.php/apps/logreader/poll?lastReqId=3out8qXe939daziLEb44 HTTP/1.1" 200 2
90.127.73.XX - - [25/Sep/2020:09:14:53 +0200] "PROPFIND /remote.php/dav/files/adrien/ HTTP/1.1" 207 388
90.127.73.XX - - [25/Sep/2020:09:14:53 +0200] "GET /ocs/v2.php/core/navigation/apps?absolute=true&format=json HTTP/1.1" 304 -
90.127.73.XX - - [25/Sep/2020:09:14:56 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 -
90.127.73.XX - - [25/Sep/2020:09:15:00 +0200] "GET /index.php/apps/photos/ HTTP/1.1" 200 27252
90.127.73.XX - - [25/Sep/2020:09:15:00 +0200] "GET /index.php/apps/photos/ HTTP/1.1" 200 27262
90.127.73.XX - - [25/Sep/2020:09:15:00 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 74
90.127.73.XX - - [25/Sep/2020:09:15:01 +0200] "SEARCH /remote.php/dav/ HTTP/1.1" 207 18862
90.127.73.XX - - [25/Sep/2020:09:15:01 +0200] "GET /index.php/core/preview?fileId=108963&x=256&y=256&a=false&v="794471213a8fd4079923f66b17f46625" HTTP/1.1" 404 2
90.127.73.XX - - [25/Sep/2020:09:15:01 +0200] "SEARCH /remote.php/dav/ HTTP/1.1" 207 18792
90.127.73.XX - - [25/Sep/2020:09:15:01 +0200] "GET /index.php/core/preview?fileId=108589&x=256&y=256&a=false&v="cc2f982ff22aadba08e4f47fce6f79c1" HTTP/1.1" 404 2
90.127.73.XX - - [25/Sep/2020:09:15:01 +0200] "GET /index.php/core/preview?fileId=108560&x=256&y=256&a=false&v="8fa4015bf8854a4eafe8aeb3dadab7b0" HTTP/1.1" 404 2
90.127.73.XX - - [25/Sep/2020:09:15:01 +0200] "GET /index.php/core/preview?fileId=108554&x=256&y=256&a=false&v="2c83ca768f2140fe63f19b6f1a150f45" HTTP/1.1" 404 2

You get a 404 error because the preview picture can not be generated. Found in another thread.

Yeah, but even with this error, it doesn’t explain the fact that the viewer doesn’t work, isn’t it ?

Yes

Perhaps you can delete all software from Imagemagick (not only PHP) and reinstall the software.

Ok I found the problem but don’t know how to solve it.
When I’m loading the photo app, my browser console returns that the viewer app is not installed (viewer.js:31 Viewer app is not installed). Weird because, there is the viewer folder in my apps folder AND I did an occ:check-app for the viewer app that didn’t return anything…

I’ve finally solved it by deleting viewer app file from apps/ and apps-pkg/ then reinstalling it manually from a backup.