Skip to content
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

Zooming out crashes egui_plot #3656

Closed
danielfaust opened this issue Nov 28, 2023 · 5 comments
Closed

Zooming out crashes egui_plot #3656

danielfaust opened this issue Nov 28, 2023 · 5 comments
Labels
bug Something is broken egui_plot Related to egui_plot

Comments

@danielfaust
Copy link

Describe the bug

In the demo located at https://www.egui.rs/#Demo, when fully zooming out from the "Custom Axes" plot example in the "Plot" window, egui will crash with a "The egui app has crashed." message

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://www.egui.rs/#Demo
  2. Click on Plot in the left pane
  3. Click on Custom Axes in the Plot window
  4. Fully scroll out with the mouse wheel while pressing Ctrl

Desktop

  • Windows 11
  • Google Chrome
  • Version 119.0.6045.160 (Offizieller Build) (64-Bit)

Desktop

  • Ubuntu 22.04
  • Firefox
  • Version 120.0 (64-Bit) canonical-002-1.0 (Mozilla Firefox Snap for Ubuntu)

Smartphone

Not reproducible due to pinch and zoom not being able to fully zoom out

@danielfaust danielfaust added the bug Something is broken label Nov 28, 2023
@Firepal
Copy link

Firepal commented Dec 11, 2023

Relevant:

fn x_grid(input: GridInput) -> Vec<GridMark> {
// Note: this always fills all possible marks. For optimization, `input.bounds`
// could be used to decide when the low-interval grids (minutes) should be added.
let mut marks = vec![];
let (min, max) = input.bounds;
let min = min.floor() as i32;
let max = max.ceil() as i32;
for i in min..=max {
let step_size = if i % Self::MINS_PER_DAY as i32 == 0 {
// 1 day
Self::MINS_PER_DAY
} else if i % Self::MINS_PER_H as i32 == 0 {
// 1 hour
Self::MINS_PER_H
} else if i % 5 == 0 {
// 5min
5.0
} else {
// skip grids below 5min
continue;
};
marks.push(GridMark {
value: i as f64,
step_size,
});
}
marks
}

It's very much possible that this is trying to draw many, many grid marks

@emilk emilk added the egui_plot Related to egui_plot label Dec 28, 2023
@emilk emilk changed the title Demo panicked at 'capacity overflow', library/alloc/src/raw_vec.rs Zooming out crashes egui_plot Dec 28, 2023
@emilk
Copy link
Owner

emilk commented Dec 28, 2023

Very similar to:

@Tweoss
Copy link
Contributor

Tweoss commented Feb 1, 2024

It does seem like the custom axes demo tries to draw many grid marks when zoomed out.

In the normal plot demo, when zooming out, I get the below. Presumably, NaN is compared against another floating point number, and the inequality doesn't hold in line 1916.

fn fill_marks_between(out: &mut Vec<GridMark>, step_size: f64, (min, max): (f64, f64)) {
assert!(max > min);
let first = (min / step_size).ceil() as i64;
let last = (max / step_size).ceil() as i64;
let marks_iter = (first..last).map(|i| {
let value = (i as f64) * step_size;
GridMark { value, step_size }
});
out.extend(marks_iter);
}

Screenshot 2024-02-01 at 10 22 17
Screenshot 2024-02-01 at 10 22 24

emilk pushed a commit that referenced this issue Jun 18, 2024
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

Can fix translating with high zoom out
#3462



* Maybe related to #3656
emilk pushed a commit to emilk/egui_plot that referenced this issue Jul 15, 2024
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

Can fix translating with high zoom out
emilk/egui#3462



* Maybe related to emilk/egui#3656
@emilk
Copy link
Owner

emilk commented Jul 15, 2024

I think this is fixed now

@emilk emilk closed this as completed Jul 15, 2024
@danielfaust
Copy link
Author

I can no longer find any plots in the demo. Have they been removed?

hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

Can fix translating with high zoom out
emilk#3462



* Maybe related to emilk#3656
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui_plot Related to egui_plot
Projects
None yet
Development

No branches or pull requests

4 participants