igoshev / laravel-captcha

Captcha integration for the Laravel
https://laravel.bonecms.tech/laravel-captcha
MIT License
79 stars 35 forks source link

Very long time to show #55

Open hrace009 opened 2 years ago

hrace009 commented 2 years ago

Captcha show with very long time, i don't know why, but this is using localhost with xampp and php 8.1 image

mishinroman94 commented 2 years ago

I have the same problem. Works fine on php 8.0

hrace009 commented 2 years ago

yeah, last time i use php7.4 it working fine, but when i switch to php8.1 the code show very long time

some0ne2 commented 2 years ago

Can confirm this, switched from working PHP7.4 to PHP8.1 (tried laravel8 and laravel9), same effect. as soon as I switch PHP to 8.1 the whole page speed is ruined.

Not usable in production. @igoshev any idea where things go wrong / can you take a look into?

hrace009 commented 2 years ago

@igoshev please make a fix for this

hrace009 commented 2 years ago

i don't see any respond from @igoshev

hrace009 commented 2 years ago

seems we must make our own fix for this package

some0ne2 commented 2 years ago

@tm1000 any idea maybe since you pushed the commit for laravel9?

some0ne2 commented 2 years ago

unusable for PHP8.1

tm1000 commented 2 years ago

@some0ne2 if you look at my commit you can see that I only bumped the composer file

Regardless my company has five services that use this on php 8.1 for the last two-three months and we've experienced no issues

some0ne2 commented 2 years ago

@tm1000 Thanks for information, what laravel version and what PHP version exactly are you using?

tm1000 commented 2 years ago

Laravel 9 and php 8.1.7

tm1000 commented 2 years ago

My coworker was confused on what I was asking. Yes we are experiencing the slowness too. The issue is all of the math in https://github.com/igoshev/laravel-captcha/blob/6694a98ed72f58e9c896308cd3fbd29a225937f9/src/Captcha/Generator/GeneratorWaves.php#L68-L136

On individual runs it takes about 0.002 seconds. However once you multiply that by each of the foreachs such as the width (120) and height (80) you get 20 seconds. The smaller the image the less time it would take.

Instead of looking into this further I just switched to: https://github.com/mewebstudio/captcha

Not the ideal solution but it works for now.

some0ne2 commented 2 years ago

@tm1000 Thanks for update, any idea why this might occur only when we switch to PHP8.1? Yes I know mewebstudio, but for us this is not ideal too, that's why we switched to this captcha lib.

tm1000 commented 2 years ago

@some0ne2 it's a bug in php not anything with this library. The math functions are slightly slower in php 8.1 and thus causes slowdowns.

tm1000 commented 2 years ago

The solution here is probably to replace WaveGenerator with code that uses https://github.com/Intervention/image to generate a similar image (this is what mewebstudio does)

The math however is used to create the wavy text

some0ne2 commented 2 years ago

Did they replace the wave generator because of the bug in PHP8.1 too?

tm1000 commented 2 years ago

@some0ne2 they dont use WaveGenerator. WaveGenerator is exclusive to this library

some0ne2 commented 2 years ago

Someone with free time available? Would provide some cups of coffee (tips) for fixing :).

hrace009 commented 2 years ago

i think we should upgrade to PHP 8.2

some0ne2 commented 1 year ago

@hrace009 Not released, anybody an update on to this? @tm1000 Thanks for verification, is this bug documented somewhere on PHP bugtracker?

hrace009 commented 1 year ago

@some0ne2 i have seen PHP 8.2 somewhere, but still in dev mode

mohammadmahdavim commented 1 year ago

hi every body Still haven't found a solution for this?

some0ne2 commented 1 year ago

Any update onto this? Someone tried 8.2 release of PHP?

tm1000 commented 1 year ago

I switched captcha providers

some0ne2 commented 1 year ago

@tm1000 any recommendation?

tm1000 commented 1 year ago

https://github.com/mewebstudio/captcha