forked from ChromeDevTools/devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 20
Add experimental Perf Issues sub-panel #217
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| // Copyright 2024 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import type * as Trace from '../../../models/trace/trace.js'; | ||
|
|
||
| export type PerfIssueSeverity = 'info' | 'warning' | 'error'; | ||
huntie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export interface RNPerfIssueDetail { | ||
| name: string; | ||
| description?: string; | ||
| severity?: PerfIssueSeverity; | ||
| learnMoreUrl?: string; | ||
| } | ||
|
|
||
| export interface PerfIssueEvent { | ||
| event: Trace.Types.Events.Event; | ||
| timestampMs: number; | ||
| } | ||
|
|
||
| export interface AggregatedPerfIssue { | ||
| name: string; | ||
| description?: string; | ||
| severity: PerfIssueSeverity; | ||
| learnMoreUrl?: string; | ||
| events: PerfIssueEvent[]; | ||
| count: number; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
front_end/panels/timeline/components/SidebarRNPerfIssueItem.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| // Copyright 2024 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import '../../../ui/components/buttons/buttons.js'; | ||
| import '../../../ui/components/icon_button/icon_button.js'; | ||
|
|
||
| import type * as Platform from '../../../core/platform/platform.js'; | ||
| import type * as Trace from '../../../models/trace/trace.js'; | ||
| import * as Buttons from '../../../ui/components/buttons/buttons.js'; | ||
| import * as UI from '../../../ui/legacy/legacy.js'; | ||
| import * as Lit from '../../../ui/lit/lit.js'; | ||
|
|
||
| import type {AggregatedPerfIssue, PerfIssueEvent, PerfIssueSeverity} from './RNPerfIssueTypes.js'; | ||
| import styles from './sidebarRNPerfIssueItem.css.js'; | ||
|
|
||
| const {html} = Lit; | ||
|
|
||
| interface SidebarRNPerfIssueItemData { | ||
| issue: AggregatedPerfIssue; | ||
| onEventSelected?: (event: Trace.Types.Events.Event) => void; | ||
| } | ||
|
|
||
| export class SidebarRNPerfIssueItem extends HTMLElement { | ||
| readonly #shadow = this.attachShadow({mode: 'open'}); | ||
|
|
||
| #issue: AggregatedPerfIssue|null = null; | ||
| #onEventSelected?: (event: Trace.Types.Events.Event) => void; | ||
| #isOpen = false; | ||
|
|
||
| set data(data: SidebarRNPerfIssueItemData) { | ||
| this.#issue = data.issue; | ||
| this.#onEventSelected = data.onEventSelected; | ||
| this.#render(); | ||
| } | ||
|
|
||
| #toggleOpen(event: Event): void { | ||
| event.preventDefault(); | ||
| this.#isOpen = !this.#isOpen; | ||
| this.#render(); | ||
| } | ||
|
|
||
| #onEventClick(issueEvent: PerfIssueEvent): void { | ||
| if (this.#onEventSelected) { | ||
| this.#onEventSelected(issueEvent.event); | ||
| } | ||
| } | ||
|
|
||
| #onEventKeyDown(event: KeyboardEvent, issueEvent: PerfIssueEvent): void { | ||
| if (event.key === 'Enter' || event.key === ' ') { | ||
| event.preventDefault(); | ||
| this.#onEventClick(issueEvent); | ||
| } | ||
| } | ||
|
|
||
| #renderDropdownIcon(isOpen: boolean): Lit.TemplateResult { | ||
| return html` | ||
| <devtools-button .data=${{ | ||
| variant: Buttons.Button.Variant.ICON, | ||
| iconName: 'chevron-right', | ||
| size: Buttons.Button.Size.SMALL, | ||
| } as Buttons.Button.ButtonData} class="dropdown-icon ${isOpen ? 'open' : ''}"></devtools-button> | ||
| `; | ||
| } | ||
|
|
||
| #renderSeverityIcon(severity: PerfIssueSeverity): Lit.TemplateResult { | ||
| const iconData = { | ||
| error: {iconName: 'issue-cross-filled', color: 'var(--icon-error)'}, | ||
| warning: {iconName: 'issue-exclamation-filled', color: 'var(--icon-warning)'}, | ||
| info: {iconName: 'issue-text-filled', color: 'var(--icon-info)'}, | ||
| } as const; | ||
| const {iconName, color} = iconData[severity]; | ||
| return html` | ||
| <devtools-icon .data=${{iconName, color, width: '16px', height: '16px'}}></devtools-icon> | ||
| `; | ||
| } | ||
|
|
||
| #render(): void { | ||
| const issue = this.#issue; | ||
| if (!issue) { | ||
| Lit.render(Lit.nothing, this.#shadow, {host: this}); | ||
| return; | ||
| } | ||
|
|
||
| const formatter = new Intl.NumberFormat(undefined, { | ||
| minimumFractionDigits: 1, | ||
| maximumFractionDigits: 1, | ||
| style: 'decimal', | ||
| }); | ||
| const contents = html` | ||
| <style>${styles.cssText}</style> | ||
| <details ?open=${this.#isOpen}> | ||
| <summary @click=${(e: Event) => this.#toggleOpen(e)} class="issue-summary"> | ||
| ${this.#renderDropdownIcon(this.#isOpen)} | ||
| ${this.#renderSeverityIcon(issue.severity)} | ||
| <span class="event-count-pill">${issue.count}</span> | ||
| <div class="issue-info"> | ||
| <div class="issue-name">${issue.name}</div> | ||
| ${issue.description ? html`<div class="issue-description">${issue.description}</div>` : ''} | ||
| ${issue.learnMoreUrl ? html` | ||
| <div class="issue-learn-more"> | ||
| ${UI.XLink.XLink.create(issue.learnMoreUrl as Platform.DevToolsPath.UrlString, 'Learn more')} | ||
| </div> | ||
| ` : ''} | ||
| </div> | ||
| </summary> | ||
| <div class="issue-content"> | ||
| <div class="event-list event-list-${issue.severity}"> | ||
| ${issue.events.map((issueEvent, i) => { | ||
| return html` | ||
| <div class="event-item" | ||
| tabindex="0" | ||
| role="button" | ||
| aria-label="Navigate to item ${i + 1} in timeline" | ||
| @click=${() => this.#onEventClick(issueEvent)} | ||
| @keydown=${(event: KeyboardEvent) => this.#onEventKeyDown(event, issueEvent)}> | ||
| <div class="event-name">${issueEvent.event.name}</div> | ||
| <div class="event-timestamp">${formatter.format(issueEvent.timestampMs)} ms</div> | ||
| </div>`; | ||
| })} | ||
| </div> | ||
| </div> | ||
| </details> | ||
| `; | ||
| Lit.render(contents, this.#shadow, {host: this}); | ||
| } | ||
| } | ||
|
|
||
| customElements.define('devtools-performance-sidebar-perf-issue-item', SidebarRNPerfIssueItem); | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'devtools-performance-sidebar-perf-issue-item': SidebarRNPerfIssueItem; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: These changes in the implementation of
TimelineFlameChartVieware necessary — since there aren't existing APIs for quite the same event selection + highlighting, with the Find panel working slightly differently.