-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Update the SCM Plugin API from the latest vscode #9045
Conversation
@vinokurig I tried this out with vscode-git-1.49.3 and https://github.com/westbury/theia which has a couple of outstanding PRs. I did get some tree errors in the console, though not many. They occurred when I committed changes. So I can understand this PR better, can you explain why those |
@westbury The theia/packages/plugin-ext/src/main/browser/scm-main.ts Lines 149 to 160 in d16c3f1
I've added a debounce to the SCM tree listener:theia/packages/scm/src/browser/scm-groups-tree-model.ts Lines 54 to 56 in e70ea71
So after the fixup there is no file-change-tree-root' does not belong to this 'file-change-tree-root errors at all.
|
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.
I've checked it and I can confirm that there are no file-change-tree-root
-related errors anymore in the browser's console. Thanks for fixing that annoying bug!
@vince-fugnitto @westbury I am going to merge it in a few days if there are no objections? |
Yes, sorry I did not get back sooner. I am a little concerned that this solution is rather trying to hide the problem rather than fix it. The change to debounce the two calls into one seems to be a bit of a hack, apart from the fact that this compromises performance by adding a 200ms delay. Would it not be better to fix it so that a second call to repository onDidChange works without error, and preferably is efficient when there are no changes? I realize we are constrained by the plugin API. I don't understand this well, and I could well be wrong. Can you wait till Monday 22nd so I can look at this in more detail? I think you have done great work identifying the problem and possible solutions, as this has been around for a while and no one had fixed it. |
Yes, sure. |
@vinokurig It would be better if we just stopped generating errors when createTree is called before the previous createTree completed. You can see how this works by using a different id each time, i.e. in the createTree method in scm-tree-model.ts, replace the id with something like Also, if we were to stick with the |
Setting a unique id fixed the problem, Could you please take a look one more time? |
@vinokurig Sorry, I did mention that if one uses a different root then the error would not occur. I was really trying to suggest alternative solutions that did not involve arbitrary delays, rather than say it was the complete solution. Making the change in your last commit on its own really is only disabling the message. As we would never have two root object instances with the same id, the test will never cause the message to be issued, and we may as well have just removed the message. That check, that the root is current, is important because it causes the original tree refresh to terminate when a new root is set. By returning from setChildren early, it is bypassing the I do note that the return value from the refresh (undefined if the root node changed) is not being checked. If you look at TreeExpansionServiceImp.init(), all children continue to be refreshed even after a refresh failed. That may be another reason why one occasionally sees the message appear many times together (especially for non-SCM trees). If a new root was set while processing a node with many children then a message will appear for each child. IMO, I think just removing the console log is the best solution. A root change is a known situation which is not a problem. It does not have to be logged, just handled properly which I believe it is. Personally I would add some comments to explain that a root change is ok and we just have to stop refreshing the old tree. @akosyakov does this sound right to you? |
@akosyakov What do you think about removing the error logging? theia/packages/core/src/browser/tree/tree.ts Lines 318 to 321 in ec4804e
|
@westbury @vince-fugnitto @akosyakov So what's the plan? Is it OK to remove the console log when tree root is changed? |
@vinokurig I do not yet fully understand the code in this area to comment if the log is no longer necessary but I feel like it is. From the commit:
|
@westbury you wouldn't get the error, but we would still have multiple tree updates going on in parallel 🤷 . I would vote we merge this PR: it improves the scm plugin implementation and makes Theia better (for me at least). We should fix the underlying problems, but I don't have a ready solution for that. |
@westbury @vince-fugnitto @akosyakov |
@tsmaeder currently the refresh of the tree stops if something else sets a new root, as described in paragraph 2 of #9045 (comment) . The only way to get two refreshes running simultanously on the same tree is, as you said, if the second refresh in on a child node. I have not seen this happen, but I can see that if one expanded a node during a refresh then it could be possible. A possible fix would be to check not just that the root node is the same instance but also check all the ancestors up to the root node. @vince-fugnitto I don't understand how it can be useful to keep the offending console logging. We know that another refresh can be started before the previous has finished. How is it useful to log that? The commit you referenced was a refactoring that fixed a problem where the root was actually being changed back if a root change was detected. As far as I know, this fix worked and I know of no remaining problems other than the child-node refresh problem. And when a refresh of a child-node occurs concurrently the console log will not be triggered. I agree that it's fine to leave this as is so we can get this PR merged. It otherwise looks fine to me but I don't really understand all the changes in scm and scm-main. Either someone else needs to look at that code or I need to spend more time understanding it. |
@westbury as I mentioned previously, I don't have the necessary knowledge in the area (unless I spend time to investigate) to determine if the logging is necessary or not, but I did encounter issues in #8911 where the logging seems to indicate a more serious error? I ended up in a a state where the log happened recursively until I ran out of memory. For such a case is the log not useful unless I'm mistaken? |
@westbury the problem is not the console message. The problem is that performance really drops when we have a lot of refresh calls. Since Tree.refresh() is API, you can call it as many times as you want, even when you don't set a new root. Therefore, I don't think checking "is it the same root object" is a sufficient stop condition for parallel updates. De-duplicating refresh calls seems a reasonable thing to do: refresh on the same tree node is idempotent so you only ever need to keep one future refresh for the same node. When I see an API like "refresh()", I would expect it to be efficient if nothing has changed. I don't really see an indication that you shouldn't call it frequently or repeatedly and the implementation will figure out if nothing relevant has changed. |
This PR has been already approved, may be you would like to suggest some one else to review this PR? |
But if I read the 'how to test' section of this PR, the removal of the console message is the requirement for testing of this PR to pass.
Yes, I don't disagree with that. I even commented that this could be fixed by checking all nodes up to the root and detecting if a later refresh has been performed on any of those nodes. But that is not the issue that this PR intended to cover. @vince-fugnitto The console message may be useful but I thought many people were complaining about it filling up the logs. Was not the point that because the refresh can be called "frequently or repeatedly and the implementation will figure out if nothing relevant has changed", we should not be polluting the log when this happens. I feel there is nothing we disagree on but are somehow just misunderstanding each other. Let's leave the issue open and comment in it the remaining performance issue. Let's leave the console log exactly as is, for now.
I had understood that @azatsarynnyy had tested for console logs, but you still needed someone to review the code and verify the Plugin API side. We don't use the Git plugin so I did not consider this my area and I just thought I should clarify that so unreviewed code was not accidentally merged. I don't know anyone to suggest so I will review the Plugin API stuff later today or tomorrow. |
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.
I assume everyone is ok with the drop of support for older Git plugins. I had a couple of minor comments/questions on the code but it looks good to me.
/** | ||
* Diffs two *sorted* arrays and computes the splices which apply the diff. | ||
*/ | ||
export function sortedDiff<T>(before: ReadonlyArray<T>, after: ReadonlyArray<T>, compare: (a: T, b: T) => number): Splice<T>[] { |
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.
Why did you need to add this function? I don't see this being used by the Theia codebase nor by the Git built-in or any other vscode build-in.
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.
Moved the sortedDiff
function to the scm.ts
/** | ||
* Represents the validation type of the Source Control input. | ||
*/ | ||
export enum SourceControlInputBoxValidationType { |
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.
Yes, it's a shame this needs to be copied here too in order to expose it as proposed API. It means we have three copies of the same interface, here, theia-proposed.d.ts, and ScmInputIssueType in the frontend. I'm not sure what to suggest that might be better so that is ok.
5a6a4a0
to
f276007
Compare
Signed-off-by: Igor Vinokur <[email protected]>
Signed-off-by: Igor Vinokur [email protected]
What it does
Update the SCM Plugin API methods from the latest vscoe.
related CQ: http://dev.eclipse.org/ipzilla/show_bug.cgi?id=23027
fixes #7953
How to test
"@theia/git": "^1.10.0"
fromexamples/browser/package.json
file.plugins
folder.See: no repeating
root ERROR Child node 'file-change-tree-root' does not belong to this 'file-change-tree-root' tree.
errors.Review checklist
Reminder for reviewers