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

GetSemanticModelAsync should not be called from UI Thread #3770

Closed
DavidKarlas opened this Issue Feb 4, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@DavidKarlas
Member

DavidKarlas commented Feb 4, 2018

@mkrueger

This comment has been minimized.

Contributor

mkrueger commented Feb 22, 2018

It's not called from ui thread - it's called async with await. I'm not sure if the hangs monitor is the issue here.

@DavidKarlas

This comment has been minimized.

Member

DavidKarlas commented Feb 22, 2018

It is called from UI thread from gtk OnExposeEvent method:
image

Even if it's called with await, there is no guarantee(or even promise) it won't execute on same thread.

@mkrueger

This comment has been minimized.

Contributor

mkrueger commented Feb 22, 2018

It's executed on the same thread when the semantic model is up2date and cached.
Creating always a task would be too much overhead. I'll discuss that with the roslyn guys.

@mkrueger

This comment has been minimized.

Contributor

mkrueger commented Feb 22, 2018

We call it always on UI thread like that - if that it would be a problem we would block all the time. So I doubt it's an issue.

@mkrueger

This comment has been minimized.

Contributor

mkrueger commented Feb 22, 2018

ATM I don't see a way to fix that - and no issue here. If you think you can improve that - try it out.
IMO it would just cause redraw flickers and not improve the UI in any way. That call can't block the UI thread and the semantic info is needed for the classifications since the roslyn classifiers are not 2 step like our old system was :(.

@mkrueger mkrueger closed this Feb 22, 2018

DavidKarlas added a commit that referenced this issue May 7, 2018

Switched from RoslynClassificationHighligthing to TagBasedSyntaxHighl…
…ighting fixes Issue #3770

This improves typing performance a lot in some cases when `GetSemanticModelAsync` takes long time(sometimes it can take multiple seconds)...
This uses advanced `AbstractAsynchronousTaggerProvider` from Roslyn that takes care of snapshot `TranslateTo` so if new classification is not ready yet, it translates old spans to requested snapshot and notifies editor when semantic classification is updated for specific span so it re-renders line containing updated classification.
There are two hacks in this commit:
 - Translations from `ClassificationTypes` to `ScopeStack` are hardcoded and so is order(same as in existing Roslyn classifier)
 - On `classifier.ClassificationChanged` event is ignored if span is whole file, reason for this is that it seems to me like SyntaxHighligher is doing this(probably can't figure out exact spans), Kirill debugged this on VS2017 and saw same behaviour, I suspect VS2017 doesn't re-render if classifications are same as in previous pass, hence it doesn't hurt them as much as it does MonoDevelop

@DavidKarlas DavidKarlas reopened this May 7, 2018

@xamarin-release-manager xamarin-release-manager added this to the 15.8 milestone May 8, 2018

Therzok added a commit that referenced this issue May 8, 2018

Switched from RoslynClassificationHighligthing to TagBasedSyntaxHighl…
…ighting fixes Issue #3770

This improves typing performance a lot in some cases when `GetSemanticModelAsync` takes long time(sometimes it can take multiple seconds)...
This uses advanced `AbstractAsynchronousTaggerProvider` from Roslyn that takes care of snapshot `TranslateTo` so if new classification is not ready yet, it translates old spans to requested snapshot and notifies editor when semantic classification is updated for specific span so it re-renders line containing updated classification.
There are two hacks in this commit:
 - Translations from `ClassificationTypes` to `ScopeStack` are hardcoded and so is order(same as in existing Roslyn classifier)
 - On `classifier.ClassificationChanged` event is ignored if span is whole file, reason for this is that it seems to me like SyntaxHighligher is doing this(probably can't figure out exact spans), Kirill debugged this on VS2017 and saw same behaviour, I suspect VS2017 doesn't re-render if classifications are same as in previous pass, hence it doesn't hurt them as much as it does MonoDevelop
@DavidKarlas

This comment has been minimized.

Member

DavidKarlas commented May 15, 2018

This was fixed with #4740

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment