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

Introduce error handling in the FemtoVG and Skia renderers #2402

Merged
merged 5 commits into from Mar 24, 2023

Conversation

tronical
Copy link
Member

Avoid unwrap() and expect() and instead propagate errors all the way down to run_event_loop(), show(), and hide() in the Slint AIP.

@tronical tronical force-pushed the simon/rendering-error-handling branch 3 times, most recently from 0075574 to 03382e7 Compare March 23, 2023 17:27
Avoid unwrap() and expect() and instead propagate errors all the way
down to run_event_loop(), show(), and hide() in the Slint AIP.
@tronical tronical force-pushed the simon/rendering-error-handling branch from 03382e7 to 90cd83e Compare March 23, 2023 17:36
let width = size.width;
let height = size.height;

let canvas = if self.canvas.borrow().is_some() {
std::cell::Ref::map(self.canvas.borrow(), |canvas_opt| canvas_opt.as_ref().unwrap())
} else {
return;
return Ok(());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks supicious. when would there be no canvas?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example if the user of the renderer API forgot to call show(). Do you think it should be an error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, i'd say:

  • misuse of API should be panic
  • runtime error should be forwared as error.

in this case, we call render but don't render anything. The user might wonder what's the bug, don't you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel too strong about it - I think it's like calling show() on a QWidget - it'll be empty (and so will be the underlying window). Do you have a preference between (1) panic (2) runtime error (3) silence?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. it feel like it shouldn't be silence. Since we can report error, we might as well do.

internal/renderers/skia/opengl_surface.rs Outdated Show resolved Hide resolved
internal/renderers/skia/opengl_surface.rs Outdated Show resolved Hide resolved
@tronical tronical merged commit 8ffb513 into master Mar 24, 2023
18 checks passed
@tronical tronical deleted the simon/rendering-error-handling branch March 24, 2023 13:18
tronical added a commit that referenced this pull request Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants