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

prevent invalid cairo matrix in expose #18420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dterrahe
Copy link
Member

prevent cairo errors reported up the chain after darkroom expose

(darktable:21578): Gtk-WARNING **: 10:11:12.748: drawing failure for widget 'GtkDrawingArea': invalid matrix (not invertible)

(darktable:21578): Gtk-WARNING **: 10:11:12.748: drawing failure for widget 'GtkBox': invalid matrix (not invertible)

(darktable:21578): Gtk-WARNING **: 10:11:12.748: drawing failure for widget 'GtkOverlay': invalid matrix (not invertible)

(darktable:21578): Gtk-WARNING **: 10:11:12.748: drawing failure for widget 'GtkGrid': invalid matrix (not invertible)

(darktable:21578): Gtk-WARNING **: 10:11:12.748: drawing failure for widget 'GtkBox': invalid matrix (not invertible)

(darktable:21578): Gtk-WARNING **: 10:11:12.748: drawing failure for widget 'GtkGrid': invalid matrix (not invertible)

(darktable:21578): Gtk-WARNING **: 10:11:12.748: drawing failure for widget 'GtkBox': invalid matrix (not invertible)

(darktable:21578): Gtk-WARNING **: 10:11:12.748: drawing failure for widget 'GtkWindow': invalid matrix (not invertible)

as reported here #18375 (comment)

Since we no longer throw away the cairo context when returning from expose (we used to copy into an extra intermediary buffer) these error conditions now persist.

@ralfbrown since you looked at this recently, do these make sense to you?

@@ -578,7 +578,7 @@ float dt_dev_get_zoom_scale(dt_dev_viewport_t *port,
zoom_scale *= (float)darktable.develop->full.pipe->processed_width
/ darktable.develop->preview_pipe->processed_width;

return zoom_scale;
return zoom_scale ?: 1.0f;
Copy link
Member

@TurboGit TurboGit Feb 14, 2025

Choose a reason for hiding this comment

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

Is that standard C? First time I see such construct? An empty section for ? means what? Return the zoom_scale here?

EDIT: Anyway, I think this should be avoided and we should be explicit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that standard C?

At least not ISO C before C2X

I don't understand the necessity of this check, line 575 already makes sure zoom_level will be non-zero.
So, you assume that full.pipe->processed_width can be zero under some circumstances?

Copy link
Member Author

Choose a reason for hiding this comment

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

So, you assume that full.pipe->processed_width can be zero under some circumstances?

No, I'm not assuming.

preview_pipe and full.pipe get processed in separate threads so there are "race" conditions where one is set and the other isn't. That occasionally leads to a zero zoom_scale and a divide by zero in the code that uses it. This used to go unnoticed because we created and threw away an intermediate cairo surface. But it gets flagged by gtk now.

I specifically asked for feedback from @ralfbrown since he made further changes touching this code since I last did any significant restructuring.

@TurboGit TurboGit added this to the 5.2 milestone Feb 14, 2025
@TurboGit TurboGit added scope: UI user interface and interactions scope: codebase making darktable source code easier to manage labels Feb 14, 2025
@pehar1 pehar1 mentioned this pull request Feb 25, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: codebase making darktable source code easier to manage scope: UI user interface and interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants