itsgoingd / clockwork

Clockwork - php dev tools in your browser - server-side component
https://underground.works/clockwork
MIT License
5.69k stars 321 forks source link

Profiler stuck on processing #591

Closed TKrisee closed 3 weeks ago

TKrisee commented 2 years ago

I'm trying to get clockwork to work with the xdebug profiler within sail (laravel docker) to no avail.

The related php.ini config

[XDebug]
zend_extension = xdebug.so
xdebug.mode = develop,debug,gcstats,profile
xdebug.start_with_request = trigger
xdebug.discover_client_host = true
xdebug.idekey = VSC
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
xdebug.use_compression = false

I've checked the previous issues regarding this topic and I disabled the compressions in the xdebug config, but it did not change anything.

The filename is present in the response header and also exists on the filesystem, but for some reason, clockwork is stuck on "Processing profile..."

Screenshot 2022-08-04 at 15 39 45

Am I missing something here?

itsgoingd commented 2 years ago

Hey, can you please send me the output of http://your.app/__clockwork/1659619567-1067-1921841239/extended to info@underground.works for further investigation?

This will contain various details about your app, please make sure you are not sharing something you are not comfortable with.

TKrisee commented 2 years ago

Hey, can you please send me the output of http://your.app/__clockwork/1659619567-1067-1921841239/extended to info@underground.works for further investigation?

This will contain various details about your app, please make sure you are not sharing something you are not comfortable with.

Sure, I've sent you a mail with two files actually, hope it will help

natenatters commented 2 years ago

Hey @TKrisee , I had a similar issue today. I was using Sail and only had to add these to the .env:

SAIL_XDEBUG_MODE=profile
SAIL_XDEBUG_CONFIG="client_host=host.docker.internal profiler_output_name=cachegrind.out.%R"

I dont know if its because of how Clockwork reads the profiler output, but this is why it works: https://github.com/underground-works/clockwork-app/issues/109#issuecomment-1252998149

brunofunnie commented 1 year ago

I know this issue is old but there's a lack of info regarding the "Performance -> Profiler" tab in Clockwork to work with Docker so let me give my two .cents of contribution

First of all, no, if you use Docker the Clockwork plugin won't magically access the files within, you'll need to create a volume outside the container and do a little of configuration, at the end is simple, steps bellow:

Xdebug ini config (explanation first)

So the xdebug.ini file will look like this:

xdebug.mode = profile
xdebug.start_with_request = trigger
xdebug.output_dir = /cache
xdebug.profiler_append = 1

Docker Compose

Your 'volumes' config in you 'docker-compose.yml' file will look something like this:

volumes:
    - '.:/var/www/html'
    - './docker/xdebug.ini:/etc/php/8.1/cli/conf.d/xdebug.ini'
    - './cache:/cache'

Also Xdebug automatically send a Http Header with the location of the profile file called 'X-Xdebug-Profile-Filename', and of course it uses the 'output_dir' config. It will look something like this:

X-Xdebug-Profile-Filename: /cache/cachegrind.out.19

Which will point to your machine's root not the project root which usually doesn't have a /cache directory (change to a different name if it does), then you'll need to create a symlink from your projects cache dir to that dir, it will look something like this:

sudo ln -s /home/<your user>/your/project/directory/cache /cache

That's all, remember to click in the Enable Profile button in the "Profiler" tab and you are good to go.

As a final advice, remember deleting your cachegrind.out file as it gets bigger pretty fast (each refresh on page) and it starts lagging the Clockwork extension when you open the Profiler tab

itsgoingd commented 1 year ago

I don't think you want to use xdebug.profiler_append, as this will cause all requests to be merged into a single profile.

devope commented 5 months ago

I have the same issue.

itsgoingd commented 3 weeks ago

Please see the updated Xdebug setup instructions on the Clockwork website - https://underground.works/clockwork/#docs-xdebug-profiler - feel free to reopen if this is still an issue for you.