-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Avoid notifying editor-only property changes #61529
Conversation
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.
Makes sense and fixes the issue, but not sure if it won't break something with LAYOUT_MODE_CONTAINER
or LAYOUT_MODE_UNCONTROLLED
as they remove the meta too.
CC @YuriSizov
@KoBeWi If your original suspicion was correct, then keeping the position layout mode that has been removed 4 commits ago would be a sufficient fix. However, later you yourself changed how checks work and removed All in all, the logic has changed too much for me to be sure, so I trust your testing more. I'd have to retest every commit done since that touched the meta to figure out possible regressions. In the original code the container and uncontrolled modes should be determinable at runtime regardless of the stored values. PS. I'm not even sure why this change fixes anything. For position mode meta was immediately removed, so the code should be equivalent, and the change is superficial. |
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.
Yeah, okay, I'm a bit more confident now that this PR doesn't change the behavior at all, so I'm not sure that the issue has been correctly identified. I agree with KoBeWi's original thought that #59185 is the culprit, and I think the fix is to actually not remove layout mode meta for position. That PR seems to be the only one that actually changed behavior, while others seem to be preserving it.
So the proper fix should be to remove remove_meta("_edit_layout_mode");
and test the reproduction then.
This would reintroduce #58940 though. |
We already store this meta if it's not the position mode. It just seems that storing it when it is the position mode is not actually unnecessary 🙃 Edit: If we can make the code clearer and avoid using meta, it'd be better. I'm just thinking short term fixing it to remove the regression. Like we've discussed, using some sort of editor metadata would probably be the way to solve this without affecting users anymore. |
This PR fixes the regression though, even if it doesn't make sense that it works. Unless you find some new issue it creates, it should be good to merge. |
I have an idea. Metadata was exposed to the inspector after the initial layout PR, right? So setting it, at any point, may trigger the inspector to update. Which isn't great, given that editor-only meta properties shouldn't even be editable in the inspector in the first place. And while this PR doesn't change the logic, it reduces the number of calls to
I'm not a fan of changing code further from the state that worked without understanding the changes. I won't block this PR if you insist on this solution, but this makes it harder and harder to maintain this delicate piece of logic based on hacks and good will. 👀 |
I actually found some flaws in the current code. They don't seem to break anything (in an obvious way at least), but we should probably fix it. First thing is that we need a default value for The problem I found in the current code is that it doesn't use default value. Line 1502 in 9b78d68
If the value doesn't exist, it will use the current value as default. That's not how defaults work... Similar thing here: Line 1591 in 9b78d68
It uses LAYOUT_MODE_ANCHORS as default, while the code changes in this PR assume LAYOUT_MODE_POSITION as default.
So here's what I propose: add As a topping to these changes, change this thing: Lines 1540 to 1544 in 9b78d68
To return (LayoutMode)int(get_meta("_edit_layout_mode", DEFAULT_LAYOUT_MODE));
It changes some logic, but I did a quick test and doesn't seem to break things. Will test again after you apply these changes. |
I believe you've introduced this code when you removed I agree with the last suggestion, though, that can be simplified. |
I know why the code was there, I just questioned whether keeping the old logic is actually necessary. |
3029081
to
ae886b3
Compare
@KoBeWi I've read through this discussion and applied the changes you suggested. Though when playing around in the editor to make sure the issue is still resolved I noticed this: When starting to drag a ColorRect, the first movement seem subject to a noticable lag/delay, after which the movement becomes smooth. Now I know to little to guess why this is and don't want to speculate. Though I did try the 3.4.2 stable release which I had sitting around and it does not have an initial lag when dragging control nodes. Though I'll check if this laging existed before #59185. |
d887450
to
c3aebfe
Compare
Something is still wrong. When layout mode is anchors, the slowdowns are still happening :/ |
You can see if this ^ is plausible. That would explain why your initial fix has an effect, for one, and why regression hasn't been noticed before. |
Not sure what you mean by "checking out the PR", I just re-added the 2 lines it removed and it fixed the lag. I didn't do much more testing.
That would be interesting. Editor metadata is not visible in the inspector, so if it was causing inspector refresh then it's a bug. |
Checking out as in check out the resulting commit of the PR. I checked it out and dragging was smooth. So I guess while re-adding the lines fixes the issue, they did not cause the performance issue by themselves. I guess this can be explained by what YuriSizov said about setting metadata triggering inspector update. I'm currently running git bisect to see where I first notice the performance regression but it will take some time. EDIT: I misspoke (or rather, was confused). The merge commit of PR 59185 on godotengine/godot does indeed introduce the lag. But on the fork that created the PR, the PR does not introduce the lagging. I'll keep investigating. |
I looked into this and it seems like the correct hypothesis. The commit 09b951b, which makes properties editable in inspector, is the first that causes the regression if combined with the changes introduced in 59185. Specifically, 09b951b adds calls to I agree that this PR is just a band-aid and not an actual solution. As said earlier, editor-only properties should not be editable in the inspector. So if these were not visible in the inspector, there would be no need to call @YuriSizov @KoBeWi do you think I have the right idea here? Then I'd be happy to draw up a new solution and create a PR. Also, since this current PR is not viable should I use the original issue for further discussion? |
Yes, I think it's reasonable that the same logic that filters properties in the inspector should be used to remove a call for update. Just to be sure, look up the code that filters meta properties, and replicate it in You can also use this PR still, remaking it for the new solution, changing the commit message and the title. But if you want to preserve it, sure, we can move back to the issue and close this. |
Yes, the metadata starting with |
It's been a hectic weekend but I finally have some time to work on this. There seems to be something weird going on with Anyways, I have some ideas what's going on and don't anticipate the solution will be too hard.. Just wanted to let people know that this is still being worked on. |
There is no need to go so in-depth with this. And thanks for doing this! |
That was my first thought. However, I considered that there might be subscribers other than And thanks for the encouragement! I'm happy to help |
c3aebfe
to
aa1089c
Compare
I assume we are waiting for a review from the core group. Or is there anything I change in the PR? |
0f36aaf
to
da1f59a
Compare
Calling Object::set_meta no longer triggers a call to notify_property_list_changed() if the changed property is editor only. This avoids triggering an inspector update for meta that is not visible in the inspector. Fixes godotengine#61343
da1f59a
to
b62a111
Compare
Looks like this is patching something that is hacky, should not not be better to fix whatever is causing the problem? |
Discussed with @reduz and decided it's better to move away from metadata all together to solve the problem with controls updating. The change that we've agreed upon in this discussion before affects core in a way that we don't really want (it's fine to have this hack in editor code, but not in core code). So we should replace control.cpp's use of metadata with hidden properties. I'll work on it this week. Sorry for taking so long, and thanks for contributing nonetheless! |
Isn't this change useful anyway? The inspector doesn't need to be refreshed for |
Related issue: #61343
Ensures that Control::_set_layout_mode() only sets
"_edit_layout_mode" meta if the layout mode is LAYOUT_MODE_ANCHORS
because the alternative, LAYOUT_MODE_POSITION, is the default
value and not needed in the meta.
This fixes #61343