Opened 12 years ago
Last modified 9 months ago
#23127 new defect (bug)
Media Upload hangs on Crunching on too big image sizes.
Reported by: | clubdesign | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 2.7 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
If the uploaded file is too big for the Max Memory Limit Setting, then the upload is executed, but the image isn't resized to the set image sizes and the frontend gets stuck on "Crunching". I tracked the error down into the core and found out, that the main problem is in the GD library class ( wp-includes/class-wp-image-editor-gd.php ) in the load() function.
Everything works fine before line 91:
$this->image = @imagecreatefromstring( file_get_contents( $this->file ) );
So imagecreatefromstring fails because of a lack of memory. But as a chain reaction everything else fails afterwards. The library is not loaded and sent back, and so on. As a result no id is sent back to the frontend and the Loader hangs.
Maybe there should be any error catching and sending back before this GD function, that the frontend receives any error messages and that the upload is deleted in case of error.
Just my thoughts: As this error is a Fatal one, you can`t use any Exception stuff, cause there will not be any memory left to execute it. Maybe some checking if the id is present before sending the image back to crunching?
Attachments (2)
Change History (30)
#7
in reply to:
↑ 1
@
11 years ago
Replying to clubdesign:
Another thought on how to prevent this thing from hanging, is to do some basic calculations before to any GD Stuff.
As this article explains there is a rough formula for that:
Width x Height x 8 (bits) x 3(channels) / 8 x 1.65
should result in the memory needed for GD. Soooo: Max availiable Memory - Wp needed memory - calc. needed memory. If negative, kick error. Just as a thought. ;)
As mentioned in #24703, it would also be nice if whatever error message is shown to the user mentions the php.ini memory_limit workaround.
#12
@
11 years ago
- Version changed from 3.5 to 2.7
Apparently this is an ages old problem - some older tickets had already been closed, so I left them alone but marked as duplicates.
#13
@
11 years ago
- Milestone changed from Awaiting Review to 3.7
Moving to 3.7. I will give it a spin this weekend.
@
7 years ago
Returns error message on fatal error, displays error message on fatal error if applicable
#20
@
7 years ago
Uploaded my first real patch, so please let me know if i did not follow protocol or standards, etc. I have code to safely return an error message in the event of a fatal error in this scenario. Also at the suggestion clubdesign, I have it estimating if it will fail and returning an wp_error. The only issue in this case is that I can't (haven't really dug into) get it to return a memory exhausted type error. Instead it just shows "An error occurred in the upload. Please try again later." which is atleast something. If the memory estimating is too unreliable, the fatal handler shows the appropriate memory error. I've also attached a sample image that will 9 times out of 10 cause a memory exhaust error for a limit of 256M. Again, any feedback is appreciated.
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
4 years ago
#24
@
4 years ago
- Keywords has-patch needs-refresh removed
- Milestone changed from Awaiting Review to 5.8
After many years it seems that this might be ready given the context of modern php and the approach in the patch being solid.
Moving this into 5.8 so we can keep an eye on it and target getting it refreshed and merged by then.
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
3 years ago
#26
@
3 years ago
In a recent Media meeting this issue was brought up and it was asked by @joyously "This is old. Wasn't this addressed fairly recently by the error processing added for image uploads?"
I think we'll need to investigate if that error handling covers this case. If not, refresh still pending and I'll get that diff uploaded very soon!
#27
@
3 years ago
- Milestone changed from 5.8 to Future Release
Today is the beta 1 deadline for 5.8. I am going to punt this one to Future Release, as there is still testing and investigation to be performed.
#28
@
9 months ago
We are facing a similar issue https://github.com/woocommerce/woocommerce/issues/30379 on WooCommerce. Could you please share any updates or planned timelines for addressing this? Thank you 🙏🏻
Another thought on how to prevent this thing from hanging, is to do some basic calculations before to any GD Stuff.
As this article explains there is a rough formula for that:
Width x Height x 8 (bits) x 3(channels) / 8 x 1.65
should result in the memory needed for GD. Soooo: Max availiable Memory - Wp needed memory - calc. needed memory. If negative, kick error. Just as a thought. ;)