Closed othmar52 closed 1 year ago
Just wanted to throw a +1 on here. We were having the same issue occasionally while running ColorThief::getPalette()
on thousands of images every day. It was rare, but it was happening enough to break/freeze our img processor cron every week or so, and eventually caused extra servers to spin up due to CPU spiking (due to this infinite loop).
Can't say if the patch above is necessarily "correct", but it does fix the infinite loop issue, thanks @othmar52. (I'd rather have this return nothing/a wrong color than freeze the entire php process).
Here's my example tiny image that was somehow triggering this issue (I can get more examples if needed):
Unfortunately I did not manage to reproduce the issue on my testing environments with the 2 images provided. This is probably due to a difference in runtime environment or parameters.
Could you please detail the runtime environment you are using (OS, with Docker ?, PHP version, image library with version) and the parameter values of the ColorThief::getPalette()
or ColorThief::getColor()
call ?
Nevertheless, I think it may be related to this commit f8f413db. Could you try to do a test after reverting this commit and tell me if that solves the problem?
Hey @ksubileau, thanks for looking into this.
I was able to recreate this issue using your lib v2.0.0 on:
(all x86_64, no docker)
We're just calling it like ColorThief::getColor($filename)
, nothing special (no optional params).
And, yes, I just confirmed reverting https://github.com/ksubileau/color-thief-php/commit/f8f413db5fdd3bce66bd864d2039bb8fb8bf006 on the original code does (also) fix the issue.
Hi, Thank you for the information provided, unfortunately I still haven't managed to reproduce the issue with any of the 2 files proposed (Ubuntu 20.04.2 x86_64 on VirtualBox, PHP 8.0.25, GD, with or without docker), but anyway, the cause and the fix are both clearly identified, so I revert the incriminated commit and release version 2.0.1.
first of all: thank you for this lib!
i experienced a freezing in one of my applictions when calling
\ColorThief\ColorThief::getColor($absolutePath, $quality)
after some debugging i found out that ColorThief did never exit a while loop
this fixed the issue for me
EDIT
i did not try to reproduce this in a vanilla scenario but the problematic file seems to be this one (extracted from id3 tags)