-
-
Notifications
You must be signed in to change notification settings - Fork 736
Add GTK4 TextInput support #3239
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
base: main
Are you sure you want to change the base?
Conversation
It looks like the test cleanup errors are reproducible on CI. Things I have tried so far:
I also tried other combinations of this, by forcing a destroy with
I'm beginning to think that this is more deeply rooted in GTK4's internal reference management. |
That's certainly possible - at which point it's a little outside our control, so skips may be our only option. Two related things that might be worth trying: First - duplicate the If that doesn't work - use
The check is being performed against |
That didn't have an impact, a second gc.collect() returns 0 so it didn't find any more objects.
Duh, of course, thanks! I created a test of GTK4 by itself, and unfortunately I wasn't able to reproduce the reference counting issue. https://gist.github.com/danyeaw/6cd58338753fd8fbb8360dcad0bc891c |
Ok - I've done some poking around, and I've found the source of the problem. Since we were getting the GTK widget impl on the list of referents, I figured it might be useful to look at that object's referents. Most of the referents to the GTK impl are of the form As an experiment, I modified the cleanup test so that it would explicitly remove the focus controller and key controller from the GTK impl before performing the GC pass (i.e., This is exactly the same logic that you tried earlier in a This hasn't historically been an issue with handlers on the GTK backend - I'm guessing the extra level of indirection introduced by the controller is making the GC loop impossible to resolve. As for how to fix this - there's a slightly analogous situation on the Winforms backend. Handlers need to be passed into Python.net, at which point the references become opaque to the Python GC, so the object can't be disposed. The solution there is to use So - I'm guessing the fix here is that we need to promote WeakrefCallable from a winforms utility to a core utility ( |
Hi @freakboy3742, thanks so much for the help with the investigation! I updated the PR with that approach. |
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.
So - the code for all this looks great... but when I looked at the tests on GTK4, it looks like they're all skipped, except for the cleanup test. I can reproduce the same thing locally - AFAICT, the only test that should be skipped (based on the probe definition) is the undo-redo test.
From the look of it, the problem is caused by the SimpleProbe base class, which is skipping all tests on GTK4. Uncommenting that skip then releases a cascade of errors...
We now have 80% of the tests passing which good. The I also decided to skip the tests simulating a keypress by the user, this is going to require a new approach for GTK4 due to the changes in events and it seemed like a containable part for another contribution. |
🎉
This is something we've seen before; it's usually an indication that the programmatic change is triggering a signal, but but then that change is altering the value of the widget, which is also detected and reported as a "change in value". However, from a quick look at the code, I agree it's not obvious why GTK4 would be firing twice here. Does raw GTK4 usage fire 2 signals on a
Sure - that makes sense. We don't need to solve every problem at once. One issue though - CI looks like it's stalling after the |
I created a minimum reproducible example with a PyGObject app and it is an upstream issue with GTK4. If you have text in an Entry, and then do a I have some additional tests to skip or fix, hopefully I can get that finished up soon. |
5289ae8
to
70ed79a
Compare
As you mentioned, tests are hanging in our CI environment (Ubuntu 24.04) but work fine for me locally (openSUSE Tumbleweed). All the problematic tests use probe.redraw() to wait for GTK to process events. I used the tmate runner to try to debug this for almost 3 hours. 🙃 On the test suite freezing, it shows the frozen test when I hit Ctrl+C, for example:
Examples of the initial tests that were hanging include: Running with In GTK4 on Ubuntu 24.04, the event processing appears to behave differently:
I have added some logic to the redraw that xfails the test after a waiting period, which was working on the runner when I tmated in, but now it looks like the runner is stuck again. I will try to also run this on Distrobox with Ubuntu 24.04 locally to see if I can reproduce the redraw errors. |
One thing to dig into here is asyncio exceptions. Consider the following:
This is, unfortunately, I suspect this may be what is happening in your test. The testbed suite uses pytest-async so that test cases and fixtures can be async; If something is crashing during setup or teardown of the test, the async task will also be stopping without displaying the error. But because the entire testbed test suite is async... the controlling task awaiting that result will also crash, and eventually, the test suite stops. But it doesn't exit, because the event loop is still running. It presents as the test suite hanging... but it's actually a complete crash of the test suite with no errors displayed. I've seen similar presentations in the past - complex dialog behaviors where you work out you're calling a method on a None object (or similar), and the test locks up as a result. I have no idea what could be causing the problem here, but it at least seems plausible as a cause. |
ebbdc4a
to
5de3cee
Compare
I was not able to reproduce the test failures using Ubuntu 24.04 locally. However, I was able to fix the freezing on CI by reworking the |
I can now reproduce the GitHub Actions failures locally, so some progress. Here are the steps:
More work to do to figure out why changes to flex styling aren't propagating correctly when running the full testbed. |
More troubleshooting:
|
Co-authored-by: Muhammad Murad <[email protected]>
Co-authored-by: Muhammad Murad <[email protected]>
Co-authored-by: Muhammad Murad <[email protected]>
Co-authored-by: Muhammad Murad <[email protected]>
This commit resolves variable binding issues in the test_cleanup function when used with pytest's parameterization. The errors appear as runtime NameErrors.
I worked on this over the last couple of days at the PyCon 2025 sprints, and also did some troubleshooting in person with @freakboy3742 (thanks Russ!). During the set-up of the test, a Box is created on the Window and the TextInput is added to it. Then it runs
|
Adds TextInput widget for GTK4 as part of #3069.
I'm getting a local test cleanup failure when trying to check that the weakref is None that I haven't been able to resolve.
PR Checklist: