记录小壹、停靠面板及画布叠层的慢帧耗时
This commit is contained in:
parent
42c87278fb
commit
f9924a8531
@ -333,6 +333,7 @@ impl PhotocraftApp {
|
||||
}
|
||||
// In Full Screen Mode, Tab shows the menu bar, options bar, toolbar and dock (#6760).
|
||||
let tabbed_in = !chrome && self.ui.panels.full_screen_chrome;
|
||||
let menu_status_start = gpu_canvas::now_ms();
|
||||
if (chrome || tabbed_in) && self.ui.panels.menu_bar {
|
||||
panels::title_bar(self, ui);
|
||||
}
|
||||
@ -342,6 +343,7 @@ impl PhotocraftApp {
|
||||
if chrome && self.ui.panels.status_bar {
|
||||
panels::status_bar(self, ui);
|
||||
}
|
||||
self.perf.stage.ui_regions.menu_status += gpu_canvas::now_ms() - menu_status_start;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if chrome { crate::jiansun::prepare(self, ui); }
|
||||
if (chrome && self.ui.panels.toolbar) || tabbed_in {
|
||||
|
||||
@ -1444,6 +1444,7 @@ struct CanvasOverlayInput<'a> {
|
||||
}
|
||||
|
||||
fn paint_primary_overlays(app: &mut PhotocraftApp, ui: &mut egui::Ui, view: &mut View, input: &CanvasOverlayInput<'_>, ants: Vec<egui::Shape>) {
|
||||
let overlay_start = crate::gpu_canvas::now_ms();
|
||||
let ctx = input.ctx;
|
||||
let painter = input.painter;
|
||||
let xf = input.xf;
|
||||
@ -1534,6 +1535,7 @@ fn paint_primary_overlays(app: &mut PhotocraftApp, ui: &mut egui::Ui, view: &mut
|
||||
crate::artboard_tool::draw_overlay(app, painter, xf);
|
||||
|
||||
draw_canvas_tool_cursor(app, ui, input, resizing);
|
||||
app.perf.stage.ui_regions.canvas_overlays += crate::gpu_canvas::now_ms() - overlay_start;
|
||||
}
|
||||
|
||||
fn draw_canvas_tool_cursor(app: &mut PhotocraftApp, ui: &mut egui::Ui, input: &CanvasOverlayInput<'_>, resizing: bool) {
|
||||
@ -2267,7 +2269,10 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let (workspace_owns_pointer, workspace_navigation, workspace_camera) = if primary {
|
||||
crate::jiansun::canvas_workspace::overlay(app, ui, xf, doc.id.0, size[0] as f32)
|
||||
let overlay_start = crate::gpu_canvas::now_ms();
|
||||
let overlay = crate::jiansun::canvas_workspace::overlay(app, ui, xf, doc.id.0, size[0] as f32);
|
||||
app.perf.stage.ui_regions.canvas_overlays += crate::gpu_canvas::now_ms() - overlay_start;
|
||||
overlay
|
||||
} else { (false, true, None) };
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let (workspace_owns_pointer, workspace_navigation) = (false, true);
|
||||
|
||||
@ -7,8 +7,6 @@
|
||||
//! into [`SlowFrames`], the last [`SLOW_FRAMES`] of them, which the control channel's `perf`
|
||||
//! output lists as `slowFrames`; one `info` log line per second names them. The stroke trace
|
||||
//! (`stroke_trace`) reads the same record, so the app times a frame in one place.
|
||||
//!
|
||||
//! On the web `now_ms()` is 0, so no frame is ever slow and the ring stays empty.
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
@ -19,6 +17,18 @@ pub const SLOW_FRAMES: usize = 64;
|
||||
/// At most one slow-frame log line per this many ms.
|
||||
const LOG_EVERY_MS: f64 = 1000.0;
|
||||
|
||||
/// UI build time per region, in milliseconds.
|
||||
#[derive(Clone, Debug, Default, PartialEq, serde::Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UiRegions {
|
||||
pub conversation: f64,
|
||||
pub production_head: f64,
|
||||
pub composer: f64,
|
||||
pub dock_panels: f64,
|
||||
pub canvas_overlays: f64,
|
||||
pub menu_status: f64,
|
||||
}
|
||||
|
||||
/// One frame's stages. Times in ms.
|
||||
#[derive(Clone, Debug, Default, PartialEq, serde::Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@ -28,6 +38,8 @@ pub struct FrameStages {
|
||||
/// The whole frame: from its start until its UI is built. Never less than the stages below
|
||||
/// (a command run between frames counts toward the next one).
|
||||
pub frame_ms: f64,
|
||||
/// Time building individual UI regions, included in `ui_ms`.
|
||||
pub ui_regions: UiRegions,
|
||||
/// From the raw input hook to the start of the UI build (input handling, minus commands).
|
||||
pub input_ms: f64,
|
||||
/// Commands run through the app since the previous frame ended.
|
||||
@ -116,8 +128,9 @@ impl FrameStages {
|
||||
pub fn line(&self) -> String {
|
||||
let opt = |v: Option<f64>| v.map_or("-".to_string(), |v| format!("{v:.1}"));
|
||||
let command = if self.command.is_empty() { String::new() } else { format!(" ({})", self.command) };
|
||||
let UiRegions { conversation, production_head, composer, dock_panels, canvas_overlays, menu_status } = self.ui_regions;
|
||||
format!(
|
||||
"slow frame: {:.1} ms on the {} path: input {:.1}, command {:.1}{command}, damage {:.1}, composite {:.1}, upload {:.1}, gpu {}, present {}; refresh {} {} px",
|
||||
"slow frame: {:.1} ms on the {} path: input {:.1}, command {:.1}{command}, damage {:.1}, composite {:.1}, upload {:.1}, gpu {}, present {}; refresh {} {} px; ui conversation {conversation:.1}, production head {production_head:.1}, composer {composer:.1}, dock panels {dock_panels:.1}, canvas overlays {canvas_overlays:.1}, menu/status {menu_status:.1}",
|
||||
self.frame_ms,
|
||||
self.path,
|
||||
self.input_ms,
|
||||
@ -269,6 +282,21 @@ mod tests {
|
||||
assert!(next.stage_ms() <= next.frame_ms);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ui_regions_are_kept_in_the_log_and_control_output() {
|
||||
let mut ring = SlowFrames::default();
|
||||
let mut stage = frame(1000.0, 0.0);
|
||||
stage.ui_regions.conversation = 38.0;
|
||||
stage.ui_regions.dock_panels = 3.0;
|
||||
ring.finish(stage, 1060.0, false, None);
|
||||
let line = ring.frames().next().unwrap().line();
|
||||
assert!(line.contains("ui conversation 38.0"));
|
||||
assert!(line.contains("dock panels 3.0"));
|
||||
let value = serde_json::to_value(&ring).unwrap();
|
||||
assert_eq!(value[0]["uiRegions"]["conversation"], 38.0);
|
||||
assert_eq!(value[0]["uiRegions"]["dockPanels"], 3.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slow_frame_log_is_rate_limited() {
|
||||
let mut r = SlowFrames::default();
|
||||
|
||||
@ -1123,6 +1123,7 @@ impl Workspace {
|
||||
visuals.widgets.active.weak_bg_fill = t.pressed;
|
||||
visuals.widgets.active.bg_stroke = Stroke::new(1.0, t.text_dim);
|
||||
|
||||
let composer_start = crate::gpu_canvas::now_ms();
|
||||
let input_id = super::composer_input_id();
|
||||
let mut focused = ui.memory(|m| m.has_focus(input_id));
|
||||
// An empty editor loses focus on toolbar press. Keep its surface in
|
||||
@ -1224,7 +1225,13 @@ impl Workspace {
|
||||
}
|
||||
});
|
||||
self.pi_ui_decorations(ui,false);
|
||||
if production { self.production_head_ui(app, ui); }
|
||||
app.perf.stage.ui_regions.composer += crate::gpu_canvas::now_ms() - composer_start;
|
||||
if production {
|
||||
let head_start = crate::gpu_canvas::now_ms();
|
||||
self.production_head_ui(app, ui);
|
||||
app.perf.stage.ui_regions.production_head += crate::gpu_canvas::now_ms() - head_start;
|
||||
}
|
||||
let conversation_start = crate::gpu_canvas::now_ms();
|
||||
let jump_id = Id::unique("jiansun-conversation-jump");
|
||||
let jump = ui.ctx().data_mut(|data| data.remove_temp::<bool>(jump_id)).unwrap_or(false);
|
||||
let timeline_viewport = ui.available_rect_before_wrap();
|
||||
@ -1376,6 +1383,7 @@ impl Workspace {
|
||||
self.panel_geometry["latestMessage"] = rect_value(response.rect);
|
||||
if response.clicked() { ui.ctx().data_mut(|data| data.insert_temp(jump_id, true)); }
|
||||
}
|
||||
app.perf.stage.ui_regions.conversation += crate::gpu_canvas::now_ms() - conversation_start;
|
||||
}
|
||||
|
||||
/// Only render request-owned snapshots; the currently selected canvas
|
||||
|
||||
@ -108,10 +108,14 @@ pub fn request_dock_width(ctx: &egui::Context, w: f32) {
|
||||
/// One dock group's tab content; `panel_docking` bounds it and scrolls it when it's taller.
|
||||
pub(crate) fn dock_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, group: crate::dock::Group, tab: usize) {
|
||||
use crate::dock::Group;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if (group, tab) == (Group::Color, 4) {
|
||||
crate::jiansun::agent_dock(app, ui);
|
||||
return;
|
||||
}
|
||||
let start = crate::gpu_canvas::now_ms();
|
||||
let pro = Tokens::get(ui.ctx()).pro;
|
||||
match (group, tab) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
(Group::Color, 4) => crate::jiansun::agent_dock(app, ui),
|
||||
(Group::Color, 2) => crate::preset_panels::gradients_panel(app, ui),
|
||||
(Group::Color, 3) => crate::preset_panels::patterns_panel(app, ui),
|
||||
// The Color tab is the same in every theme, in the mode picked from its panel menu
|
||||
@ -132,4 +136,5 @@ pub(crate) fn dock_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, group: crate
|
||||
(Group::Layers, _) => crate::vector_ui::paths_panel(app, ui),
|
||||
(Group::Brushes, _) => crate::brushes_tab::show(app, ui),
|
||||
}
|
||||
app.perf.stage.ui_regions.dock_panels += crate::gpu_canvas::now_ms() - start;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user