-
Notifications
You must be signed in to change notification settings - Fork 326
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
Fix visualizations sometimes not opening with space bar. #5624
Fix visualizations sometimes not opening with space bar. #5624
Conversation
…tion opening do not erroneously close the visualisation as if it was opened as preview.
lib/rust/web/src/lib.rs
Outdated
let frames: Counter = default(); | ||
let frames_handle = Rc::clone(&frames); | ||
let closure_handle = Rc::new(RefCell::new(None)); | ||
let closure_handle_internal = Rc::clone(&closure_handle); |
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 a memory leak here? The closure strongly-references the closure handle, which owns the closure.
lib/rust/web/src/lib.rs
Outdated
type Counter = Rc<std::cell::Cell<i32>>; | ||
|
||
#[derive(Debug)] | ||
/// A counter that counts frames thr frames that have passed since its initialization. |
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.
Typo
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.
Please address the leak issue by @kazcw
app/gui/view/graph-editor/src/lib.rs
Outdated
/// Number of frames we expect to pass during the | ||
/// `VIZ_PREVIEW_MODE_TOGGLE_TIME_MS` interval. Assumes 60fps. | ||
const VIZ_PREVIEW_MODE_TOGGLE_FRAMES: i32 = (VIZ_PREVIEW_MODE_TOGGLE_TIME_MS / 16.0) as i32; |
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 we assume 60 FPS I would rather put here 1000.0/60.0. Or make assumed FPS another constant
…with_space_does_not_always_work_#5223
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 need a better explanation of why this PR works and what was the cause that visualizations were disappearing. The code is probably fine, but it should explain itself for future readers
app/gui/view/graph-editor/src/lib.rs
Outdated
@@ -94,6 +94,10 @@ pub mod prelude { | |||
|
|||
const SNAP_DISTANCE_THRESHOLD: f32 = 10.0; | |||
const VIZ_PREVIEW_MODE_TOGGLE_TIME_MS: f32 = 300.0; | |||
/// Number of frames we expect to pass during the | |||
/// `VIZ_PREVIEW_MODE_TOGGLE_TIME_MS` interval. Assumes 60fps. |
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 lacks documentation of what these constants do. Please add docs to previous constant as well. Also, the explanation Number of frames we expect to pass during the...
doesn't really explain what it means and what it is used for.
app/gui/view/graph-editor/src/lib.rs
Outdated
// We also check the number of passed frames to ensure we did not spend too much time in | ||
// dropped frames during the visualisation initialisation. |
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 does it mean? What is "too much time"? There is no explanation why this code exists and what it really does.
The problem here is, that we are trying to measure the time between the key down and the key up event. If the key up event happens before the I'll now update the docs to make this clearer. |
…with_space_does_not_always_work_#5223
…with_space_does_not_always_work_#5223
…with_space_does_not_always_work_#5223
…with_space_does_not_always_work_#5223
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.
Perfect, now it is fully understandable, thanks!
@kazcw Could you also re-review tour requested changes? |
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.
QA passed
…with_space_does_not_always_work_#5223
…with_space_does_not_always_work_#5223
Pull Request Description
Visualizations closing right after opening was caused by the GUI being unresponsive during loading of some visualizations. This caused the timer for measuring the time between space bar press and space bar release to be inflated. The delayed events triggered the "visualization preview mode”, thus closing the visualization has it seemed that the space bar was held down, even though the events just arrived with some delay.
The problem is mitigated by considering the number of frames that have passed between the space and down and the space bar up event, instead of just the wall clock time. If the number of frames is too low, this indicates that frames were dropped to the time is inflated.
Fixes #5223
Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.