Skip to content

[WebProfilerBundle] Add settings to have the profiler follow the browser #54638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

jtattevin
Copy link

@jtattevin jtattevin commented Apr 17, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
License MIT

Often during development, we load a page, check some informations in the profiler, see something wrong, fix, reload the page, reload the profiler. That mean that we often reload the profiler page.
If we can use the 'latest' token it's ok, but if there is another controller called (for example a webmanifest), we either need to search for it or close the tab, then reopen a new tab.

This change use the BroadcastChannel javascript api to broadcast to other tabs that a toolbar have loaded or that an ajax request have finished. The profiler page listen to this broadcast and load the new profiler page based on the token broadcasted. A new setting allow to choose if :

  • We don't want this behavior
  • We want to follow only the main requests where a toolbar is shown (default)
  • We also want to follow ajax call captured by the toolbar

The settings section look like that :
image

I didn't submit a PR to the doc side, as it seem that there is no section related to the settings.

ro0NL

This comment was marked as outdated.

@jtattevin
Copy link
Author

💯 is there any reason to not follow the browser by default?

To keep the same behavior than before, I often compare two profiler page, so having the profiler follow by default would break this workflow, I find better to have the user opt-in for that

@jtattevin
Copy link
Author

jtattevin commented Apr 18, 2024

Thank for the feedback, it helped to refine the idea.

The current default setting look like that :
image

So now by default, it track the browser, and don't load automatically.

When a page load is detected, it look like that :
image
The link is focused by default, so if you change tab, you can validate by pressing enter

For the automatic part, depending on the feedback, i may remove it from the PR and keep it as a local change only as i'm not sure if the way it's done currently is the best way and i don't find another method that would work better.
If the profiler change automatically, this toolbar is shown :
image
The go back link is a javascript link to go back.
The toolbar disapear after 10s after being shown to the user.

@smnandre
Copy link
Member

This feature seems very nice!

Personally, when working on a webapp I almost every time have multiple "web" pages open and multiple profiler tabs, and i really would not want them to be refreshed without my active action ;)

@@ -292,6 +292,7 @@
profilerCell.appendChild(profilerLink);
}

broadCastToken(request.profile, "ajax", request.url);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
broadCastToken(request.profile, "ajax", request.url);
if (request.profilerUrl) {
broadCastToken(request.profile, "ajax", request.url);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch ! I didn't think about element that was not profiled.

I've made the change and moved the block to be near the logic of reloading the toolbar if needed, so that we only trigger once the broadcasting. I check for request.profile instead of request.profilerUrl to be more consistent with the parameter of the function and the toolbar replace behavior

@jtattevin jtattevin force-pushed the ProfilerRefresh branch 2 times, most recently from 2b4d365 to 0cef377 Compare April 20, 2024 09:00
@jtattevin
Copy link
Author

On the last PR, i've made a change to use sessionStorage (which is tab scoped) to track if you want to follow the browser or not.
That way you can have a profiler automatically tracking the page and open in new tabs the profiler you want to keep.

By default, you'll have this toolbar shown :
image

If you click on "Follow the browser automatically", then this tab only will begin following and will look now like that :
image

And then, when a new page is loaded, the toolbar is updated to show that the page was reloaded with an option to disable this behavior :
image

This also mean that the checkbox that was in the settings was removed.

@nicolas-grekas nicolas-grekas modified the milestones: 7.1, 7.2 May 2, 2024
…ser.

Often during development, we load a page, check some informations in the profiler, see something wrong, fix, reload the page, reload the profiler.
That mean that we often reload the profiler page.
If we can use the 'latest' token it's ok, but if there is another controller called (for example a webmanifest), we either need to search for it or close the tab, then reopen a new tab.

This change use the BroadcastChannel javascript api to broadcast to other tabs that a toolbar have loaded or that an ajax request have finished.
The profiler page listen to this broadcast and show a toolbar with the new profiler page based on the token broadcasted.
A new setting allow to choose if :
- We don't want this behavior
- We want to follow only the main requests where a toolbar is shown (default)
- We also want to follow ajax call captured by the toolbar
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants