Thumbnails not appearing with attachments > 10MB

Started by davo88, November 27, 2023, 07:51:51 PM

Previous topic - Next topic

davo88

Firstly, well done and many thanks to the coders who re-wrote the original 2.1.0 attachment UI and refined it to the current 2.1.4 version.
Fantastic job and much appreciated.

The following tests were done on a fresh install of 2.1.4, no mods or other alterations.
cPanel - PHP Options
- max_execution_time = 60
- max_input_time = -1
- memory_limit = 1024M
- post_max_size = 256M
- upload_max_filesize = 64M

SMF Attachment settings
- Max attachment size per post = 262144
- Max size per attachment = 22000
- Thumbnail size 225 x 225.

I have been exploring the upper limits of attachment posting on a new server.
The issue is that something stops the attachment thumbnails from appearing during the upload sequence once the attachment size gets over approx 10MB.
Note they do appear OK once the post is saved.
You cannot view this attachment.

Once we get into very large sizes (15-20MB), no thumbnails appear until the post is saved.
You cannot view this attachment.
Other tests with attachments of 6-9MB all displayed thumbnails correctly during uploading.
I am not sure if this limitation is caused by SMF or PHP or something else.
This is not an immediate issue as we can work under these limits for now. However it may become one in the future as our forum encourages posting photos even if not resized.

Sesquipedalian

If your users are uploading enormous image files, it is entirely possible for the memory requirements to create a thumbnail to exceed the amount of memory that your host server is willing to allocate to PHP.

You could try asking your host to change the server configuration in order to allow more memory to be allocated to PHP. They might make you pay more for that, though.

You could also go to Administration Center ► Attachments and Avatars ► Attachment Settings and turn off the "Resize images when showing under posts" setting. This will disable thumbnail creation, causing SMF to use the full size images instead of thumbnails. The downside to this option is that your pages will take a lot longer to load and will use a lot more bandwidth.

Your third option is to impose a size limit on file uploads.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

davo88

Quote from: Sesquipedalian.... it is entirely possible for the memory requirements to create a thumbnail to exceed the amount of memory that your host server is willing to allocate to PHP.

Do you think 1024MB would be insufficient? That is the PHP setting these tests were done with. 3GB is the total amount of RAM available.
 

Kindred

It might be insufficient.
It's not only size of the original file, but dpi, and file type, as well as what your host has allowed and what graphics manipulation tool they have built php with...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

davo88

Increased the RAM size in PHP Options to 2048M and ran a couple of tests again, but the same 10MB limit seems to be in effect.
I notice in PHP options the 'gd' extension is checked. I don't know anything about graphics extensions, but is there another one worth trying?
The purpose of this exercise is just to find out where the upper limits are in case they are ever needed in the future. We won't be allowing such large attachments for our members in the near term.

Kindred

The limits for file conversion are definitely part of your SERVER configuration -- so your host would be the proper group to talk to...    If you won't actually NEED a 10 MB file supported, then I suggest setting your file size limits to 9MB and calling it a day. Otherwise, it seems like you are doing alot of work for no real purpose.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Diego Andrés

Could be an issue for a photo site, some 4k pics tend to be heavy.
Assuming it's not a host problem though, which could still be.

SMF Tricks - Free & Premium Responsive Themes for SMF.

davo88

In cPanel > PHP Selector > Extensions, I tried disabling 'gd' and enabling the 'imagick' image processing library instead. But images > 10MB still did not produce thumbnails during the uploading sequence. Imagick did seem to produce the thumbnails a little quicker than gd.

The interesting thing about this issue is that thumbnails are produced correctly for images > 10MB once the post is saved. It is only during the uploading sequence that the 10MB limit seems to come into effect.

Kindred

SO far, I continue to read this as "not an SMF bug..."
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Diego Andrés

test


Edit: No issues, can't replicate.

You cannot view this attachment.



I did run into this one: https://github.com/SimpleMachines/SMF/issues/7817

SMF Tricks - Free & Premium Responsive Themes for SMF.

davo88

Thanks for doing the test Diego.
The issue only occurs when uploading images greater than 10MB. Images under 10MB all produce thumbnails OK during uploading. As far as I can tell, all the images in your test were less than 10MB so they all produced thumbnails during upload OK. The hosting supplier is helping out and so far has suggested monitoring the browser console and the SMF error log. So I did another test and monitored those during the upload, but nothing appeared in either. He seems to be a very helpful fellow so we will see what eventuates.

Quote from: kindredSO far, I continue to read this as "not an SMF bug..."
I posted it here because I don't know what is the cause. Even if not something to do with SMF, I thought it may be of interest to the coders. If you feel this topic is more relevant in another forum, please go ahead and move it. There may be other admins whose sites need to handle large image sizes for some reason. So understanding the cause may be helpful to them too.


Sesquipedalian

Quote from: davo88 on November 28, 2023, 12:55:40 PMThe interesting thing about this issue is that thumbnails are produced correctly for images > 10MB once the post is saved. It is only during the uploading sequence that the 10MB limit seems to come into effect.

That is interesting. It suggests that the problem is not a memory limit causing the operation to abort, as I had previously suspected.

My new suspicion is that the operation is simply taking longer to complete than the maximum timeout value that either the server or your browser is configured to wait for. Please note that the JavaScript that SMF uses to handle the file uploads does not set a timeout for this, but the server or the browser might set their own timeouts.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

davo88

When the upload stage is complete for a single attachment (green bar completes the left to right movement), there is a brief pause and then a thumbnail either appears or it doesn't. It then moves straight on to uploading the next attachment - there isn't really much of a delay. It looks more like the size of the uploaded file is not meeting some criteria than a timeout.

To make sure, I increased the two values in PHP options 'max_execution_time' and 'max_input_time' to 600 secs but this made no difference.

Also tried posting in three browsers - Chrome, Firefox and Brave - all behave the same. The hosting supplier also installed SMF on one of his servers and was able to reproduce the result. Will keep looking and trying stuff.


live627

have you checked for javascript errors in the browser's dev tools?

davo88


Quote from: live627... in the browser's dev tools?

I have checked the console tab in dev tools. Is that where I should look for error messages?

TwitchisMental

#15
I can replicate this issue. @Sesquipedalian 

SMF 2.1.4
Apache 2.4.58
MariaDB 10.4.32
PHP 8.1.25

You cannot view this attachment.

davo88

Here is a series of image sizes just below and above 10MB.
- The last one to upload and display a thumbnail successfully (0I1A1439.JPG) is 9.91 MB (10,397,367 bytes) according to Windows file properties.
- The first one to not display a thumbnail successfully (0I1A1322.JPG) is 10.0 MB (10,520,415 bytes) according to Windows file properties.
These attachments were uploaded one file at a time and this behaviour has been consistent in every test so far. There seems to be a very clearly defined cut off point at 10MB.

You cannot view this attachment.
List of files used in this test.
0I1A1470.JPG - 10,220,109 bytes - thumbnail
0I1A1447.JPG - 10,255,669 bytes - thumbnail
0I1A1453.JPG - 10,364,683 bytes - thumbnail
0I1A1439.JPG - 10,397,367 bytes - thumbnail
0I1A1322.JPG - 10,520,415 bytes - no thumbnail
0I1A1438.JPG - 10,552,857 bytes - no thumbnail
0I1A1437.JPG - 10,602,085 bytes - no thumbnail
0I1A1323.JPG - 10,636,269 bytes - no thumbnail
0I1A1440.JPG - 10,718,503 bytes - no thumbnail

davo88

After posting, all thumbnails appear normally.

You cannot view this attachment.

Sesquipedalian

@TwitchisMental and @davo88:

Thanks for the confirmation. As @live627 asked, do you see any errors in your browser's JavaScript console when this happens?
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

davo88

Quote from: Sesquipedalian... do you see any errors in your browser's JavaScript console when this happens?

Browser is Chrome.

The only one visible is this one relating to favicon.ico which I didn't think was connected to the attachment uploading issue.

You cannot view this attachment.

However when I click on the red symbol on the right of '5 issues', these appear. I am not sure if these are connected to the attachment uploading or not.

You cannot view this attachment.


You cannot view this attachment.

Advertisement: