-
Notifications
You must be signed in to change notification settings - Fork 321
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
Improving Performance Monitor #5895
Conversation
…sten on window and some on root.
Co-authored-by: Kaz Wesley <kaz@lambdaverse.org>
// === Exports === | ||
// =============== | ||
|
||
// Re-exported here so it can be referenced by macro-generated code. |
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.
Why removed this comment? Isn't it useful?
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.
It causes enso-formatter
to fail on this file.
@@ -247,6 +246,11 @@ impl InstanceModel { | |||
fn set_layer(&self, layer: Layer) { | |||
layer.apply_for_html_component(&self.scene, &self.root_node) | |||
} | |||
|
|||
fn set_active(&self, active: bool) { | |||
let val = if active { "all" } else { "none " }; |
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.
val
->attribute
as it says a bit more.- Is the space after "none" necessary?
@@ -105,13 +105,13 @@ impl Application { | |||
let data = &self.inner; | |||
let network = self.frp.network(); | |||
enso_frp::extend! { network | |||
eval self.display.default_scene.frp.focused ((t) data.show_system_cursor(!t)); |
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.
show_system_cursor
name is a bit misleading as it sometimes hides it. set_system_cursor
maybe?
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.
I'd disagree on that one. show_system_cursor(false)
is more understandable to me than set_system_cursor(false)
. However, I'd love to chat about it more if you want :)
} | ||
|
||
impl MouseManager { | ||
/// Constructor. | ||
/// Constructor. See docs of `new_separated` to learn more. |
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.
/// Constructor. See docs of `new_separated` to learn more. | |
/// Constructor. See docs of [`Self::new_separated`] to learn more. |
Or new_separated
.
You can check in IntelliJ if the doc links work by changing to rich mode, clicking on the links and check if proper docs are displayed.
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.
/// 1. A DOM object to set resize observer on. This object should cover the entire screen. | ||
/// Since EnsoGL's scene origin is positioned in the left-bottom corner, the size of | ||
/// the DOM object is used to translate mouse coordinates from HTML to the EnsoGL space. | ||
/// | ||
/// 2. A DOM object to set the 'mousedown', 'mousewheel', and 'mouseleave' listeners on. | ||
/// In most cases, this should be the canvas used by EnsoGL. Alternatively, you can set | ||
/// this argument to the window object if you want EnsoGL to capture all events, even if | ||
/// it is placed behind another DOM element. | ||
/// | ||
/// 3. A DOM object to set the 'mouseup' and 'mousemove' listeners on. In most cases, | ||
/// this should be the window object. It is common for the element drag action to be | ||
/// initiated by a 'mousedown' event on one element and finished by a 'mouseup' event | ||
/// on another element. Handling these events globally covers such situations. | ||
pub fn new_separated( |
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.
If those three differ "in most cases", then perhaps this should be a main constructor, and new
should be called differently or just removed to not encourage people to make things unusual.
// ================================================================================================= | ||
// === Samplers ==================================================================================== | ||
// ================================================================================================= |
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.
This "Long heading" even more suggests splitting the file into submodules. We should not have modules requiring three tiers of headings.
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.
It was like that (I know this is not an explanation). Im refactoring it rn.
lib/rust/frp/src/io/js.rs
Outdated
@@ -91,82 +91,42 @@ fn event_listener_options() -> enso_web::AddEventListenerOptions { | |||
/// `pass_to_dom` event will be emitted. | |||
/// | |||
/// To make this class manage js event, you should wrap the closure passed as event listener using | |||
/// `make_event_handler` function. | |||
/// `handler` function. |
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.
Update the docs. We do not have "pass_to_dom" anymore.
In fact, I'm not sure if we need this function anymore. Before, we wanted to keep JsEvent
to be able to call "prevent_default" if nobody allowed passing it to DOM. Now, I don't see any scenario where we need global access to currently processed event.
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.
I'm not sure here. I like this structure, as it wraps all JS events in FRP. I'd leave it this way, as it should not affect performance (we are doing that only once when registering bindings) and it gives nice FRP access to all JS events. Seems handy. Docs updated.
/** Removing `pointer-events` handling from brush element, as we want it to be inherited. D3 inserts | ||
* `pointer-events: all` in the brush element and some of its children on brush creation and after brushing ends. */ |
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.
Is there any documentation to link, or is it just your discovery? You can add this little info to the comment.
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.
It's my discovery, but you are right, I'm adding a better description there
let (watch_cmd_name, mut watch_cmd_opts) = match std::env::var("USE_CARGO_WATCH_PLUS") { | ||
Ok(_) => ("watch-plus", vec!["--why"]), | ||
Err(_) => ("watch", vec![]), | ||
}; | ||
watch_cmd_opts.push("--ignore"); | ||
watch_cmd_opts.push("README.md"); | ||
|
||
watch_cmd | ||
.kill_on_drop(true) | ||
.current_dir(&context.repo_root) | ||
.arg("watch") | ||
.args(["--ignore", "README.md"]) | ||
.arg(watch_cmd_name) | ||
.args(watch_cmd_opts) |
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.
Add documentation of this feature somewhere.
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.
Added to contributing guide.
fn run_stats(&self, time: Duration) { | ||
let previous_frame_stats = self.stats.begin_frame(time); | ||
if let Some(stats) = previous_frame_stats { | ||
self.on.prev_frame_stats.run_all(&stats); | ||
self.stats.calculate_prev_frame_fps(time); | ||
{ | ||
let stats_borrowed = self.stats.borrow(); | ||
self.on.prev_frame_stats.run_all(&stats_borrowed.stats_data); | ||
} | ||
self.stats.reset_per_frame_statistics(); | ||
} |
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.
I know it's from older code, but I don't quite get what "running stats" means in this context. It is about displaying them?
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.
where is "running stats" there? run_all
refers to running all registered callbacks.
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.
In the method name. But indeed, I missed that those inside are callbacks.
} | ||
|
||
/// Ends tracking data for the current animation frame. | ||
/// Also, calculates the `frame_time` and `wasm_memory_usage` stats. | ||
pub fn end_frame(&self) { | ||
self.rc.borrow_mut().end_frame(); | ||
} | ||
|
||
/// Register a new draw call for the given symbol. | ||
pub fn new_draw_call(&self, symbol_id: SymbolId) { |
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.
new_
is so strongly associated with constructors
const PADDING_LEFT: f64 = 8.0; | ||
const PADDING_TOP: f64 = 8.0; | ||
const FONTS: &str = | ||
"\"SF Pro Text\",\"SF Pro Icons\",\"Helvetica Neue\",\"Helvetica\",\"Arial\",sans-serif"; |
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.
r#"Raw quotes"#
would avoid the backslashes here.
details: web::HtmlDivElement, | ||
selection_offset: Cell<f64>, | ||
plot_area: MainArea, | ||
control_button: ControlButton, | ||
} | ||
|
||
impl Dom { | ||
/// Constructor. | ||
#[allow(clippy::new_without_default)] |
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.
Unnecessary lint.
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.
Rust should tell about it :( Thanks for catching it!
let on_pause_press = Rc::new(on_pause_press); | ||
let on_play_press = Rc::new(on_play_press); | ||
let on_main_press = Rc::new(on_main_press); | ||
Self { rc, on_pause_press, on_play_press, on_main_press } | ||
} | ||
} | ||
|
||
|
||
impl DomData { | ||
/// Constructor. | ||
#[allow(clippy::new_without_default)] |
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.
Unnecessary lint.
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.
Rust should tell about it :( Thanks for catching it!
pub fn move_selection(&self, offset: f64) -> usize { | ||
let start_x = self.config.plot_x(); | ||
let end_x = self.config.plot_right_x(); | ||
let width = end_x - start_x - 1.0; |
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.
Magic 1.0
. Is it the selection width?
let selection_border = config.plot_selection_border; | ||
let selection_width = config.plot_selection_width + 2.0 * selection_border; | ||
let selection_left = | ||
config.plot_right_x() - 0.5 - config.plot_selection_width / 2.0 - selection_border; |
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.
What's 0.5
here?
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.
It's centering of selection. I refactored the code to be more obvious and moved it to
let selection_center = (config.plot_selection_width + 1.0) / 2.0;
Is it ok now?
let pause_icon = "<svg width=\"16\" height=\"16\"> | ||
<circle cx=\"8\" cy=\"8\" r=\"8\" fill=\"#00000020\" /> | ||
<rect x=\"5\" y=\"4\" width=\"2\" height=\"8\" style=\"fill:#00000080;\" /> | ||
<rect x=\"9\" y=\"4\" width=\"2\" height=\"8\" style=\"fill:#00000080;\" /> | ||
</svg>"; | ||
|
||
let play_icon = "<svg width=\"16\" height=\"16\"> | ||
<circle cx=\"8\" cy=\"8\" r=\"8\" fill=\"#00000020\" /> | ||
<polygon points=\"6,4 12,8 6,12\" style=\"fill:#00000080;\" /> | ||
</svg>"; |
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.
Raw quotes would be easier to read here.
let panel_index = ((position.y as f64 | ||
- PADDING_TOP | ||
- self.user_config.outer_margin | ||
- self.user_config.margin / 2.0) | ||
/ (self.user_config.margin + self.user_config.panel_height)) | ||
.floor() as usize; | ||
let panel_index = panel_index.max(0).min(self.panels.len() - 1); |
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.
.max(0)
should be done before converting to an unsigned type
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.
Oh, good point!
} | ||
} | ||
|
||
fn set_focus_sample(&mut self, index: Option<usize>) { |
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.
It seems like some additional logic would be necessary to handle index=None
, but this function is never used that way. Maybe index: usize
?
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.
Thanks for catching it!
fn shift_plot_area_left(&mut self, dom: &Dom) { | ||
let width = self.width; | ||
let height = self.height; | ||
let shift = -(self.config.plot_step_size); | ||
dom.context | ||
dom.plot_area | ||
.plot_context | ||
.draw_image_with_html_canvas_element_and_sw_and_sh_and_dx_and_dy_and_dw_and_dh( |
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.
What a name, web_sys
😆
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.
Yeah, it's hilarious :D
QA ✔️ 🎉
|
QA ReportNavigating a full screen Geo Map still seems to affect the scene underneath. Also, I've found several issues with visualization, but they turned out to be present also on develop. Here I put list for reference:
|
@farmaazon as these are not regressions, I'll merge it still. The thing that the full-screen visualizations work is an accidental fix here nad TBH I don't know why it's fixed, I was not digging into it. So this issue with geo map needs investigation and digging deeper. |
Pull Request Description
This PR improves the Performance Monitor and the way we handle JavaScript events in the application.
Important Notes
In particular, this PR introduces the following changes:
Screen.Recording.2023-03-17.at.06.59.22.mov
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.