spatie / ray

Debug with Ray to fix problems faster
https://myray.app
MIT License
574 stars 102 forks source link

Window version freezes and CPU spikes after dumping a specific object #593

Closed sunscreem closed 2 years ago

sunscreem commented 2 years ago

Describe the bug Super keen to start using ray but found a problem straight out of the gate. It works great until I dump a particular object then it freezes (some function still work but mostly its frozen) and CPU usage jumps to 100% for about 2 minutes.

Versions

1.18.3

PHP version: 8.0.10 Laravel version (if applicable): 8.62.0

To Reproduce I can dump most things into Ray no problem but this specific object makes the central screen freeze for about 1-2 minutes.

Screenshots image

Desktop (please complete the following information):

Let me know if there's anything I can provide to help diagnose this.

sunscreem commented 2 years ago

I'm not sure if this helpful but when I dump the same object to the console instead I notice it's HUGE.

(I'm using Statamic which seems to have a lot of routes coming up in the dump)

sunscreem commented 2 years ago

Okay - further investigation and I found that dumping any object that contains an instance of the laravel url() helper causes Ray to crash.

freekmurze commented 2 years ago

I tried this code

ray(url());
ray('Ray still works');

And using all the latest releases, that seems to be working.

CleanShot 2021-11-11 at 10 47 47@2x
sunscreem commented 2 years ago

Thanks @freekmurze. When I'm trying the same it crashes. I'm now fairly convinced that the payload being sent to ray is absolutely huge.

image

The problem is I can't prove it as I can't work out how to see the payload being sent.

If I dd() or Log::info in both cases they just return the string url.

Could you point me to where I could dump the payload?

AdrianMrn commented 2 years ago

I can reproduce this on my intel Mac, however I don't think this is something we can reliably deal with as the url() helper is over 0.5MB in size and needs to be evaluated by the symfony dump script to get the collapsibles to work.

I've loosened the rules by which the log table decides whether to rerender items, this might help your case a bit, but I think it won't solve it 100% :(

@freekmurze is there anything we can do in the laravel package to prevent huge logs from reaching the app, or somehow trimming them?

freekmurze commented 2 years ago

I'm afraid we can't solve this easily...

AdrianMrn commented 2 years ago

@sunscreem if this is a critical issue that you cannot work around, I'll consider adding a "low-performance" option (no offence implied 🙈) in the app, which stops huge logs from being evaluated. This isn't a perfect solution, as it would stop you from being able to collapse the items in the dumps, but it would at least stop the app from freezing.

Let me know what you think!

sunscreem commented 2 years ago

@AdrianMrn I reworked my application to just use a string instead of the url() helper in the end. It sort of messes with my brain as when I dd(url('whatver')) you just get a string, yet with ray it's trying to send the huge payload as you suggested. Weird one!