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

Gtk4 port #223

Merged
merged 24 commits into from
Aug 14, 2024
Merged

Gtk4 port #223

merged 24 commits into from
Aug 14, 2024

Conversation

jwahlstrand
Copy link
Collaborator

@jwahlstrand jwahlstrand commented Jul 2, 2023

This is ready to try now.

@jwahlstrand jwahlstrand marked this pull request as ready for review September 17, 2023 23:11
@codecov
Copy link

codecov bot commented Sep 17, 2023

Codecov Report

Attention: Patch coverage is 81.66667% with 11 lines in your changes missing coverage. Please review.

Project coverage is 87.37%. Comparing base (fef1437) to head (896e0fc).
Report is 4 commits behind head on master.

Files Patch % Lines
src/ProfileView.jl 81.66% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #223      +/-   ##
==========================================
+ Coverage   87.24%   87.37%   +0.12%     
==========================================
  Files           1        1              
  Lines         298      301       +3     
==========================================
+ Hits          260      263       +3     
  Misses         38       38              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@nhz2 nhz2 left a comment

Choose a reason for hiding this comment

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

Looks good with a few patches. I tested this on Windows using the default example. Here is a screenshot:
image

Project.toml Outdated
@@ -27,8 +27,8 @@ Colors = "0.9, 0.10, 0.11, 0.12"
FileIO = "1.6"
FlameGraphs = "0.2.10, 1"
Graphics = "0.4, 1"
Gtk = "1.2"
GtkObservables = "1"
Gtk4 = "0.5"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd like to keep 0.5 compat as well.

src/ProfileView.jl Outdated Show resolved Hide resolved
src/ProfileView.jl Show resolved Hide resolved
src/ProfileView.jl Outdated Show resolved Hide resolved
Project.toml Outdated
@@ -27,8 +27,8 @@ Colors = "0.9, 0.10, 0.11, 0.12"
FileIO = "1.6"
FlameGraphs = "0.2.10, 1"
Graphics = "0.4, 1"
Gtk = "1.2"
GtkObservables = "1"
Gtk4 = "0.5"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd like to keep 0.5 compat as well.

Copy link
Contributor

@nhz2 nhz2 left a comment

Choose a reason for hiding this comment

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

Looks good. I also tested on Linux using Pop!_OS 22.04.
Everything in the GUI works like in the previous version.

I get the warning:

(process:31294): Gtk-WARNING **: 17:38:16.184: No IM module matching GTK_IM_MODULE=ibus found

when opening the viewer, and the following when saving or opening a "testdata.jlprof" file.

(process:31294): Gtk-WARNING **: 17:46:52.667: Attempting to add 'file:///home/nathan/github/ProfileView.jl/testdata.jlprof' to the list of recently used resources, but no name of the application that is registering it was defined

But these don't seem to cause any issues.

image

@jwahlstrand
Copy link
Collaborator Author

I don't see those warnings on Fedora, but they're basically harmless. I wish GTK had a mechanism to silence stuff like that.

@IanButterworth
Copy link
Collaborator

What's the status of this?

On MacOS it seems to work (though the text on the canvas is a little blurry?) and I see no terminal warnings.

Screenshot 2024-08-04 at 10 04 31 PM

@IanButterworth
Copy link
Collaborator

I wonder if the low resolution issue I'm seeing is related to the failure of this test on MacOS.. perhaps the range of sz is too small

sz = size(ProfileView.flamepixels(ProfileView.FlameGraphs.default_colors, g))
mktemp() do path, io
redirect_stdout(io) do
for j in 1:sz[2], i in 1:sz[1]
c.mouse.buttonpress[] = MouseButton(XY{UserUnit}(j, i), 1, GtkObservables.BUTTON_PRESS, btn.modifiers)
end
end
flush(io)
@test occursin("MethodInstance", read(path, String))

@jwahlstrand
Copy link
Collaborator Author

I get the warning:

(process:31294): Gtk-WARNING **: 17:38:16.184: No IM module matching GTK_IM_MODULE=ibus found

when opening the viewer, and the following when saving or opening a "testdata.jlprof" file.

(process:31294): Gtk-WARNING **: 17:46:52.667: Attempting to add 'file:///home/nathan/github/ProfileView.jl/testdata.jlprof' to the list of recently used resources, but no name of the application that is registering it was defined

The second of these warnings should be gone in the most recent version of Gtk4.

@jwahlstrand
Copy link
Collaborator Author

jwahlstrand commented Aug 5, 2024

On the resolution issue, I wonder if the scaling should be modified for HiDPI displays? Never mind, the text doesn't look tiny. Like you said, it's blurry.

Test failed for me locally on MacOS but with a different error. Adding additional sleep fixed it, and the CI error too.

@IanButterworth
Copy link
Collaborator

Seems like the blurry text rendering is a known and unsolved issue https://gitlab.gnome.org/GNOME/gtk/-/issues/3787

If you think this is ready, I say we go ahead.

@IanButterworth
Copy link
Collaborator

IanButterworth commented Aug 5, 2024

Oh, actually, we're on GTK v4.12 and it's claimed this got better in v4.14
https://www.phoronix.com/news/GTK-4.14-Crisper-Font-Rendering

https://blog.gtk.org/2024/03/07/on-fractional-scales-fonts-and-hinting/

@timholy
Copy link
Owner

timholy commented Aug 5, 2024

Sorry for my inattention (too many updates needed for Julia 1.11 in the Revise/Cthulhu/SnoopCompile etc stack).

I'll start playing with this, but @jwahlstrand feel free to merge whenever you are ready (you have an invite now).

@jwahlstrand
Copy link
Collaborator Author

Thanks, I'll check one more thing this evening. The weird thing about the font issue is, we're not using GTK to draw the text, it's all Cairo. For me, it's still quite readable, so I think it's worth going ahead.

I'll try to update Yggdrasil to GTK 4.14 soon.

disable rounded corners for GtkFrame
adapt to different bounding box behavior in GtkObservables v2
are the Macs just not catching a MethodInstance?
@jwahlstrand
Copy link
Collaborator Author

The CI error came back and I think it was happening because the Profile didn't contain much of anything on MacOS, for some reason. Increasing the number of iterations in the profiled function seems to have fixed it.

I'm seeing an issue locally, only on my Mac. When ProfileView precompiles, using it right away doesn't work. Sometimes the windows don't appear, sometimes I see the following error, no matter what I try to profile:

Warning: There were no samples collected.
│ Run your program longer (perhaps by running it multiple times),
│ or adjust the delay between samples with `Profile.init()`.

But if I quit Julia and restart it, ProfileView works fine. So it seems like precompiling is having some sort of side effect. It's puzzling because ImageView has similar precompile code and works fine. I want to look into this a bit more before merging.

@timholy
Copy link
Owner

timholy commented Aug 12, 2024

Thanks for your careful work here! I don't have a Mac, nor any good ideas except to wonder if Mac isn't using COW across forked processes? https://softwareengineering.stackexchange.com/questions/244664/global-variable-in-a-linux-shared-library

@IanButterworth
Copy link
Collaborator

I think there's a bigger issue on macOS. See JuliaLang/julia#53816 (comment)

@jwahlstrand
Copy link
Collaborator Author

I commented out the precompile code that causes issues on my Mac (which involves observable handlers). I don't notice any difference in performance so I'm going to merge this PR and investigate later.

@jwahlstrand jwahlstrand merged commit 303c193 into timholy:master Aug 14, 2024
9 of 10 checks passed
@timholy
Copy link
Owner

timholy commented Aug 14, 2024

Thank you @jwahlstrand ! You're a true hero!

@jwahlstrand jwahlstrand deleted the gtk4 branch August 22, 2024 22:05
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.

4 participants