ionide-vscode-fsharp
ionide-vscode-fsharp copied to clipboard
Ionide hangs when writing a comment having a certain format.
Describe the bug
When writing ~~a comment~~ a text having a format //.*``.*\(.*\).*``.+
, Ionide slows down and hangs in the end.
To Reproduce Steps to reproduce the behaviour:
- Open any F# file.
- ~~Start commenting.~~
- Input
``()``
and keep pushinga
. It will look like//``()``aaaaaaaaaaa...
. - VSCode hangs.
Expected behaviour Nothing bad happens.
Environment (please complete the following information):
- OS: Debian GNU/Linux buster/sid
- Ionide version: 3.35.0
- VSCode version: 1.33.1
- dotnet SDK version: 2.2.203
- mono / .Net Framework version: Mono 5.20.1.19
Additional context This bug does not happen while using fsharp-language-server, so I think it is somewhat related to Ionide.
Just to confirm that this also happens if you don't comment i.e. you can omit step 2 above.
At first, I would have said that the issue is coming from the grammar.
But after checking grammar of both fsharp-language-server
and Ionide
they are almost the same.
fsharp-language-server is using ionide-fsgrammar too but trailling a bit behind
The only difference between both grammar is this one:
![Capture d’écran 2019-04-25 à 20 35 15](https://user-images.githubusercontent.com/4760796/56759629-a9ec3e80-6799-11e9-9560-3512ac5339b8.png)
As you can see it's just adding support for static let mutable
.
And if you say that fsharp-language-server
doesn't have the problem. Then the grammar is probably not the source of the issue.
@MangelMaxime I tested it right now and I'm pretty sure fsharp-language-server
does not have the problem. Hope this helps :pray:
I can't repro it with Ionide 4 so I think it has been fixed.
hmm, I just reproduced it with Ionide 4.0.4, .NET Core 3.0.100, VSCode 1.36, Debian buster/sid.
I also confirmed that fsharp-language-server
does not have the problem (the same behavior as before).
Here is an interesting screenshot: when the problem is happening, the code
process is eating up the CPUs while the dotnet
process (FSAC) is not.
When I input aaaaaa...
, the cpu usage of dotnet
process spikes for a very short period of time and returns to normal, while code
process uses considerable CPU % for much longer time.
Hope this helps!
@cannorin You may have found a new issue there.
I was running the experimental branch (apparently 0.3.5) and I was able to reproduce this still. I then uninstalled and installed the main branch (4.0.4) and the issue was gone. When I uninstalled and re-installed experimental 0.3.5, the issue is still gone... maybe try having a play with re-installing or swapping the extension out?
Edit: actually, this doesn't seem to be resolved.
The situation was improved (i.e. vscode didn't hang completely) but CPU spikes were still there. Then when I restarted vscode, the original issue was back and it hangs completely, so I'm rather confused. It appears this is reproducible i.e. a fresh install works but CPU load is high, whereas upon re-opening vscode the original issue is back and it hangs completely.
C:\Program Files\dotnet\dotnet.exe" c:\Users\user\.vscode-insiders\extensions\ionide.experimental-fsharp-0.3.5/bin_netcore/fsautocomplete.dll --mode lsp --background-service-enabled
is the process that's CPU hungry for me.
@drk-mtr I can reproduce that. Reinstalling and swapping the extension temporarily solves the problem, and the fresh install don't have the problem, but it's back after restarting VSCode in both cases.
I still can repro, on latest VSCode Insider + latest Ionide
And.... I can still repro.
I did another test in order to isolate the problem, if I deactivate the F# grammar using:
{
"name": "fsharp",
"scopeName": "source.fsharp",
"fileTypes": [
"fs"
],
"foldingStartMarker": "",
"foldingStopMarker": "",
"patterns": [
],
"repository": {
}
}
The problem still exist, which confirm that the grammar is not the problem.
I'm having this issue as well. Any non-alphanumeric character while writing between backticks hangs VSCode. I'm guessing, since this has been open for over a year, that no fix is incoming?
@clindholm I guess we sinply don't know why this happens?
@cannorin I did some testing to see if I could narrow it down a bit more. There is no problem opening files that already have extra characters in backtick functions (I don't know if they have some special name). I disabled autosuggestions which didn't resolve the issue, but it seems to me that it made it less severe. Where before, I had to force quit vscode, it now sometimes become responsive after a few seconds. It freezes when I click anywhere inside the backtick fucntion name. And then if it unfreezes, the whole name is highlighted. So maybe it has something to do with the code that decides the highlight range of a function name?
A few updates on this:
- I still get the issue with Ionide
v5.2.0
- It occurs on macOS and Linux
- Happens most often when writing test names. Seems to hang when in the cursor is in the middle of the backticks name:
open Xunit
open FsUnit.Xunit
[<Fact>]
let ``hangs when changing the test name`` () =
true |> should equal true
- After restoring VS Code from the crash, it will lock-up again. Editing the file in Vim and then restoring VS Code will make the issue go away.
Since this was happening to me quite often, and it seems to be a hard bug to trace, I left the F# output open while editing.
Whilst working on some tests (tests are named with backticks like ``this is my test``
) it happened again!
Here are the last lines of the output before it froze:
[14:39:20.170 VRB] [Checker] Current Queue Length is 0
[14:39:20.170 INF] [Checker] TryGetRecentCheckResultsForFile - "/home/path/to/file/Test.fs"
[Error - 14:39:20] Request textDocument/hover failed.
Message: Cannot find ident for tooltip
Code: -32603
Happy to provide mode details.
Same thing is happening to me. Somehow, it will also hang other vs code instances. A way to easily trigger this is to add a ;
at the end of a test like such:
let ``this is a test;`` () =
The following consistently reproduces the problem for me:
Steps
- Create a new xUnit project.
dotnet new xunit --lang F#
. - Start VS Code,
code .
- Wait for Ionide to load the project.
- Change the name of the unit test to something like the following:
When naming the unit test do not include a comma in the name
- Insert a comma into the name.
Expected Behavior
VS Code editor does not hang.
Actual Behavior
VS Code editor hangs and a dialog appears stating, "The window is no longer responding."
Workaround
Do not include commas in the unit test names.
Environment
- Windows 10
- VS Code 1.56.2
- Ionide-fsharp v5.5.5
Still happens
In my steps to reproduce above, I had this workaround:
Do not include commas in the unit test names.
Today, hyphens are causing this same hang behavior for me. For example,
let ``Get does not throw for non-existent id ()`` =
Maybe I should have said:
Do not include ~commas~ non-alphanumeric characters in the test names.
Apologies for the off topic comment but I really appreciate how people are posting genuinely useful debugging info above, and no irate "still not fixed!?" or any comments like that, the sign of a good community, full respect!
In my steps to reproduce above, I had this workaround:
Do not include commas in the unit test names.
Today, hyphens are causing this same hang behavior for me. For example,
let
Get does not throw for non-existent id ()=
Maybe I should have said:
Do not include ~commas~ non-alphanumeric characters in the test names.
@Wallace-Kelly You saved my day! Apparently, a hyphen (-) inside ``…``` made VS Code crash every time I opened the file. Now that I have removed the hyphen, everything is back to normal.
After returning to my project after a few months, I noticed a new problem with VS Code hanging when I open an F# file with tests. My tests use double-backtick quoting for names. At first I thought it was this same issue, but now I'm not sure. I definitely had problems that match the descriptions here in the past until I took out special characters from my test names (everything except letters and spaces) and then it was fine. The new problem seems a bit different, however it's related closely enough that I want to add it here first.
The new problem seems more like it has to do with the number of characters after the backtick qouting, even though it's not part of the backtick quoting. The problem does not occur when Ionide is disabled and occurs when it is the only extension enabled. After some trial and error, I've found what seems to be the minimal repro.
Repro:
- Create new F# library with
dotnet new classlib -lang f#
- Open folder in VS Code
- Open Library.fs and erase everything but the namespace
- On a new line, type a double-backtick (erase the closing double-backtick if it adds it automatically) then type letters until you observe VS Code become unresponsive and hang. For me it starts to lag at text column 29 and hangs completely at column 35.
Observations
- The issue still occurs if the line is commented out beforehand with
//
or(* *)
- If you have the closing double-backticks, you can type all the text you want between them with no problem. However if you add text after it, you get the same problem
- The slowdown/hang occurs not just when the cursor is on the line with the backtick quoting, it happens when it is merely on the screen at all
@mattstermiller Well done! I followed your instructions and see the exact same behavior... the lag becomes noticeable around column 29.
There is some interesting data if you take a dump of processes when this hang occurs - last time I took a look (~2 month ago), The FSAC process (which handle typechecking and some semantic highlighting) was at <2% CPU, and the VSCode renderer process was going haywire.
This signals to me that the textmate regexes might bear investigations again. I know in the past we've tried to eliminate it from consideration, but that's just what I saw.
Hello @baronfel,
I re-tested different configurations:
Test scenario
-
Open a file
test.fsx
which contains the following codelet ``Get does not throw for non-existent id ()`` = ""
-
If using Ionide wait for it to kicks up (see the
// string
inline hint) or have the hover feature working -
Place the cursor in the middle of the function name
-
Add some random text to it
Ionide from marketplace 7.0.0 (standard usage)
Results:
- When placing the cursor in the function name there is a freeze.
- Writing letter per letter is freezing for 5-10sec and then ok
- Writing normally make the application freeze and ask we want to make it crash/reopen.
Note: We can't really test Ionide without a grammar because if we disable it by editing the configuration of from the marketplace extension there will still be the default one from VSCode loaded.
Grammar without Ionide
Results:
Everything is working fine
F# Language Server updated from marketplace 0.1.82
Results:
Everything is working fine
dotnet fsautocomplete
+ Sublime Text LSP
Results:
Everything is working fine
@baronfel
Compare to previous assumptions it seems like the problematic combination is Ionide + VSCode.
As FSAC seems to be working correctly when used from Sublime text.