ionide-vscode-fsharp icon indicating copy to clipboard operation
ionide-vscode-fsharp copied to clipboard

Ionide hangs when writing a comment having a certain format.

Open cannorin opened this issue 5 years ago • 24 comments

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:

  1. Open any F# file.
  2. ~~Start commenting.~~
  3. Input ``()`` and keep pushing a. It will look like //``()``aaaaaaaaaaa....
  4. 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.

cannorin avatar Apr 15 '19 06:04 cannorin

Just to confirm that this also happens if you don't comment i.e. you can omit step 2 above.

drk-mtr avatar Apr 25 '19 18:04 drk-mtr

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

Diff online

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 avatar Apr 25 '19 18:04 MangelMaxime

@MangelMaxime I tested it right now and I'm pretty sure fsharp-language-server does not have the problem. Hope this helps :pray:

cannorin avatar Apr 26 '19 01:04 cannorin

I can't repro it with Ionide 4 so I think it has been fixed.

MangelMaxime avatar Jul 08 '19 10:07 MangelMaxime

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.

Screenshot from 2019-07-09 02-25-30

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 avatar Jul 08 '19 17:07 cannorin

@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 avatar Jul 08 '19 20:07 drk-mtr

@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.

cannorin avatar Jul 09 '19 02:07 cannorin

I still can repro, on latest VSCode Insider + latest Ionide

Krzysztof-Cieslak avatar Jul 12 '19 20:07 Krzysztof-Cieslak

And.... I can still repro.

Krzysztof-Cieslak avatar Jan 17 '20 22:01 Krzysztof-Cieslak

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.

MangelMaxime avatar Feb 10 '20 11:02 MangelMaxime

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 avatar Sep 22 '20 22:09 clindholm

@clindholm I guess we sinply don't know why this happens?

cannorin avatar Sep 23 '20 00:09 cannorin

@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?

clindholm avatar Sep 23 '20 01:09 clindholm

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.

njlr avatar Jan 26 '21 16:01 njlr

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.

njlr avatar Feb 01 '21 14:02 njlr

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;`` () =

FrankBro avatar Feb 02 '21 00:02 FrankBro

The following consistently reproduces the problem for me:

Steps

  1. Create a new xUnit project. dotnet new xunit --lang F#.
  2. Start VS Code, code .
  3. Wait for Ionide to load the project.
  4. 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
  5. 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."

image

Workaround

Do not include commas in the unit test names.

Environment

  • Windows 10
  • VS Code 1.56.2
  • Ionide-fsharp v5.5.5

WallaceKelly avatar Jun 06 '21 22:06 WallaceKelly

Still happens

OnurGumus avatar Apr 13 '22 17:04 OnurGumus

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 avatar Jun 09 '22 18:06 Wallace-Kelly

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!

drk-mtr avatar Jun 09 '22 19:06 drk-mtr

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, letGet 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.

bytesource avatar Jul 25 '22 10:07 bytesource

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:

  1. Create new F# library with dotnet new classlib -lang f#
  2. Open folder in VS Code
  3. Open Library.fs and erase everything but the namespace
  4. 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 avatar Aug 12 '22 21:08 mattstermiller

@mattstermiller Well done! I followed your instructions and see the exact same behavior... the lag becomes noticeable around column 29.

Wallace-Kelly avatar Aug 12 '22 21:08 Wallace-Kelly

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.

baronfel avatar Aug 12 '22 21:08 baronfel

Hello @baronfel,

I re-tested different configurations:

Test scenario

  1. Open a file test.fsx which contains the following code

    let ``Get does not throw for non-existent id ()`` =
        ""
    
  2. If using Ionide wait for it to kicks up (see the // string inline hint) or have the hover feature working

  3. Place the cursor in the middle of the function name

  4. 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.

MangelMaxime avatar Aug 16 '22 09:08 MangelMaxime