Unable to perform preview generation

Hello all,

I am facing an issue with the preview apps and i need som help

Nextcloud version _(eg, 20.0.5)_: **20.0.9.1**
Operating system and version _(eg, Ubuntu 20.04)_: **CentOS 7.7**
Apache or nginx version _(eg, Apache 2.4.25)_:  **nginx v1.16.1**
PHP version _(eg, 7.4)_: **7.4.19**

Is this the first time you’ve seen this error? (Y/N): N

It is a freh install of nextcloud in this environement, one external share using SMB where data (photos) are stored (~150GB), I need to create all the preview.

When I use the follwoing command line (sudo -u nginx php occ preview:generate-all -vvv) the process fail after ~5hours with the following error output on the command line:

An unhandled exception has been thrown:
TypeError: strlen() expects parameter 1 to be string, bool given in /home/nginx/nextcloud/apps/files_external/3rdparty/icewind/smb/src/StringBuffer.php:48
Stack trace:
#0 /home/nginx/nextcloud/apps/files_external/3rdparty/icewind/smb/src/StringBuffer.php(48): strlen()
#1 /home/nginx/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Native/NativeReadStream.php(57): Icewind\SMB\StringBuffer->read()
#2 [internal function]: Icewind\SMB\Native\NativeReadStream->stream_read()
#3 /home/nginx/nextcloud/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php(55): fread()
#4 /home/nginx/nextcloud/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php(96): Icewind\Streams\Wrapper->stream_read()
#5 [internal function]: Icewind\Streams\CallbackWrapper->stream_read()
#6 /home/nginx/nextcloud/lib/private/Preview/ProviderV2.php(92): file_put_contents()
#7 /home/nginx/nextcloud/lib/private/Preview/Image.php(50): OC\Preview\ProviderV2->getLocalFile()
#8 /home/nginx/nextcloud/lib/private/Preview/GeneratorHelper.php(63): OC\Preview\Image->getThumbnail()
#9 /home/nginx/nextcloud/lib/private/Preview/Generator.php(244): OC\Preview\GeneratorHelper->getThumbnail()
#10 /home/nginx/nextcloud/lib/private/Preview/Generator.php(140): OC\Preview\Generator->getMaxPreview()
#11 /home/nginx/nextcloud/lib/private/PreviewManager.php(205): OC\Preview\Generator->generatePreviews()
#12 /home/nginx/nextcloud/apps/previewgenerator/lib/Command/Generate.php(203): OC\PreviewManager->generatePreviews()
#13 /home/nginx/nextcloud/apps/previewgenerator/lib/Command/Generate.php(174): OCA\PreviewGenerator\Command\Generate->parseFile()
#14 /home/nginx/nextcloud/apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder()
#15 /home/nginx/nextcloud/apps/previewgenerator/lib/Command/Generate.php(172): OCA\PreviewGenerator\Command\Generate->parseFolder()
#16 /home/nginx/nextcloud/apps/previewgenerator/lib/Command/Generate.php(155): OCA\PreviewGenerator\Command\Generate->parseFolder()
#17 /home/nginx/nextcloud/apps/previewgenerator/lib/Command/Generate.php(123): OCA\PreviewGenerator\Command\Generate->generateUserPreviews()
#18 /home/nginx/nextcloud/lib/private/User/Manager.php(571): OCA\PreviewGenerator\Command\Generate->OCA\PreviewGenerator\Command\{closure}()
#19 /home/nginx/nextcloud/apps/previewgenerator/lib/Command/Generate.php(124): OC\User\Manager->callForSeenUsers()
#20 /home/nginx/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OCA\PreviewGenerator\Command\Generate->execute()
#21 /home/nginx/nextcloud/3rdparty/symfony/console/Application.php(1000): Symfony\Component\Console\Command\Command->run()
#22 /home/nginx/nextcloud/3rdparty/symfony/console/Application.php(271): Symfony\Component\Console\Application->doRunCommand()
#23 /home/nginx/nextcloud/3rdparty/symfony/console/Application.php(147): Symfony\Component\Console\Application->doRun()
#24 /home/nginx/nextcloud/lib/private/Console/Application.php(215): Symfony\Component\Console\Application->run()
#25 /home/nginx/nextcloud/console.php(100): OC\Console\Application->run()
#26 /home/nginx/nextcloud/occ(11): require_once('/home/nginx/nex...')
#27 {main}

Steps to replicate it:

  1. Launch the command to generate all preview: sudo -u nginx php occ preview:generate-all -vvv

I set DEBUG level on log located in /var/log/nextcloud/nextcloud.log, here the last line when the error occurs

{"reqId":"FZcwVikZ6o3Yx2bnnbxK","level":0,"time":"May 16, 2021 14:13:01","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"OC_Image->fixOrientation() Orientation: 6","userAgent":"--","version":"20.0.9.1"}
{"reqId":"FZcwVikZ6o3Yx2bnnbxK","level":0,"time":"May 16, 2021 14:14:08","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"OC_Image->fixOrientation() Orientation: 6","userAgent":"--","version":"20.0.9.1"}
{"reqId":"FZcwVikZ6o3Yx2bnnbxK","level":0,"time":"May 16, 2021 14:15:18","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"OC_Image->fixOrientation() Orientation: 6","userAgent":"--","version":"20.0.9.1"}
{"reqId":"FZcwVikZ6o3Yx2bnnbxK","level":0,"time":"May 16, 2021 14:16:05","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"OC_Image->fixOrientation() Orientation: 6","userAgent":"--","version":"20.0.9.1"}

The output of your Nextcloud log in Admin > Logging: no error

The output of the config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxx',
  'secret' => xxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'fake-URL1',
    2 => 'fake-URL2',
  ),
  'dbtype' => 'mysql',
  'version' => '20.0.9.1',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'dbuser',
  'dbpassword' => 'fake-dbpassword',
  'installed' => true,
  'instanceid' => 'xxxxxxxxxxxxx',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => 0,
  'logdateformat' => 'F d, Y H:i:s',
  'maintenance' => false,
  'mysql.utf8mb4' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => '127.0.0.1',
  'mail_smtpport' => '25',
  'mail_smtptimeout' => 10,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'admin',
  'mail_domain' => 'fake-fqdn',
  'mail_sendmailmode' => 'smtp',
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' =>
  array (
    0 => 'admin',
  ),
 'twofactor_enforced_excluded_groups' =>
  array (
  ),
  'overwrite.cli.url' => 'https://fake-URL2',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
);

In addition, I did a modification following this https://blog.nuvotex.de/nextcloud-smb-stringbuffer/ as I encoutered first an issue regarding data size calculation (https://github.com/nextcloud/server/issues/26457)

Could you help me because I did not have any idea to find the root cause?

Thank you !

Hello
in order to update I just open an issue here : https://github.com/nextcloud/previewgenerator/issues/235

Hello
I am still stuck, no one has any idea to submit to me to find the root cause?
thank you

Hello
I did find a solution
thank you