vscode-as3mxml icon indicating copy to clipboard operation
vscode-as3mxml copied to clipboard

Intellisense only working for a few seconds

Open cgascons opened this issue 3 years ago • 35 comments

Hi, for some reason the Intellisense autocompletion only works for the first few seconds (~30s) after opening a new project. Afterworks it will hang and only shows the "Loading" tooltip where the box with suggestions should appear. I also noticed the editor footer message "Initialising ActionScript & MXML language server" stays there for a really long time.

Besides this, not sure if related but after a few attempts to use the editor (launch the game, close it, edit code, compile and relaunch and so on) it seems that many java processes are being created and never killed automatically by vscode, which ends up slowing down my mac to the point of having to manually kill them to be able to continue working.

image

cgascons avatar Nov 16 '20 08:11 cgascons

I also noticed the editor footer message "Initialising ActionScript & MXML language server" stays there for a really long time.

But it eventually disappears, right?

joshtynjala avatar Nov 16 '20 17:11 joshtynjala

When this happens, can you open the "Output" view in VSCode, and switch the drop down to "ActionScript & MXML Language Server" and copy/paste any error messages that you find in there?

joshtynjala avatar Nov 16 '20 17:11 joshtynjala

But it eventually disappears, right?

That's correct, after a few seconds its' gone.

When this happens, can you open the "Output" view in VSCode, and switch the drop down to "ActionScript & MXML Language Server" and copy/paste any error messages that you find in there?

Tried to do this today, no luck. The output tab is empty. What I noticed anyways is something related to this issue. It looks like as I type some code the Problems tab gets filled with hundreds of issues, then after a few seconds gets back to normal, like if it was trying to compile the whole project every time I type a character. It's weird because that issue appears as closed and should not be happening.

It's worth noting that I'm dealing with a quite big project, which depends on custom libraries, in this particular case this project is using 3 custom libraries (added to workspace as well), perhaps is having a hard time because of that?

Hope this info helps in any way.

cgascons avatar Nov 17 '20 08:11 cgascons

It's interesting that hundreds of problems appear. I would expect maybe a few at most while typing, since you'll have bad syntax for a short time between certain characters, but not hundreds. That does indeed make it seem like it's trying to compile your whole project from scratch. However, typing in a single file should not cause the whole project to be re-validated. Part of my fix for #205 was to focus only on the current file, and then to check the rest of the project on save.

Your issue sounds to me like it may be #420 instead. That is still unsolved because no one has been able to share a project with me to try to reproduce it on my Mac. All of my own projects are working correctly on that machine.

joshtynjala avatar Nov 17 '20 18:11 joshtynjala

I understand, I will try to create a sample project to replicate this issue.

When this happens, can you open the "Output" view in VSCode, and switch the drop down to "ActionScript & MXML Language Server" and copy/paste any error messages that you find in there?

By the way, today I did get some info in the Output tab, here it is:

Nov 18, 2020 9:26:37 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 7
Nov 18, 2020 9:26:37 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 1
Nov 18, 2020 9:26:44 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 13
Nov 18, 2020 9:26:44 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 12
Nov 18, 2020 9:26:44 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 10
Nov 18, 2020 9:26:46 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 24
Nov 18, 2020 9:26:46 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 23
Nov 18, 2020 9:26:46 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 17
Nov 18, 2020 9:26:47 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 33
Nov 18, 2020 9:26:47 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 27
Nov 18, 2020 9:26:52 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 42
Nov 18, 2020 9:26:52 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 43

cgascons avatar Nov 18 '20 08:11 cgascons

By the way I did not tell you, it does look like indeed we are facing the same issue stated in https://github.com/BowlerHatLLC/vscode-as3mxml/issues/420. I have anyways (in case it helps somehow), gathered a sample of the stuck/high cpu java process in the Activity monitor as seen here:

image

And this this is the sample text received (could not add the sample text here because the it exceeds the maximum characters for a comment). Notice that I'm using java 1.8.0 for this specific project but it also happens when using newer versions of java, I will try today if this happens as well with a different computer.

cgascons avatar Nov 18 '20 09:11 cgascons

By the way, today I did get some info in the Output tab, here it is:

Thanks! Unfortunately, this is just normal behavior.

Hoping you can put together a sample project. At the very least, your asconfig.json might have some clues, but a full project would be ideal.

joshtynjala avatar Nov 18 '20 17:11 joshtynjala

I will definitely try to make that sample project for you. In the meantime the asconfig.json I'm currently using is the same that I pasted on a past issue here https://github.com/BowlerHatLLC/vscode-as3mxml/issues/388#issuecomment-708562425, in case it helps you find something while I try to replicate this on a smaller project.

cgascons avatar Nov 19 '20 08:11 cgascons

Thanks. There are a couple of interesting things in your asconfig.json that I can play around with to try to reproduce the issue. FRESteamWorks.ane is specified three different times in the compiler options. Plus, its parent folder is specified twice, meaning that it might actually be referenced five times. You have a "\n" character in additionalOptions, which I wouldn't have expected that to work at all, and it might be having side effects. Tomorrow is my day to work on VSCode stuff, so I'll check it out then.

joshtynjala avatar Nov 19 '20 17:11 joshtynjala

I did some more investigating this morning. Unfortunately, I still don't know how to reproduce on my Mac. However, I did find a code path that is most likely the cause of this behavior:

It looks like as I type some code the Problems tab gets filled with hundreds of issues, then after a few seconds gets back to normal, like if it was trying to compile the whole project every time I type a character.

In the extension, there's a didChange() method that is called whenever you change the contents of an editor in VSCode. Normally, it can successfully find a "compilation unit" for the specified file path, and everything works great. If there is no compilation unit for a file path, it tries to compile the whole project, and that should create the missing compilation unit. Again, everything should be great after that. What seems to be happening is that the compilation unit is never getting created (or maybe the file path doesn't quite match up, for some reason). Once I am able to reproduce, this method should be a good place for me to find some more clues.

joshtynjala avatar Nov 20 '20 20:11 joshtynjala

Once I am able to reproduce, this method should be a good place for me to find some more clues.

Thank you very much for looking into this. I will try to find time this week to make a replicable project though is going to be difficult because I also believe it only happens on large projects.

Funny thing though, if I leave the project long enough open after editing it, there's a moment where the intellisense auto-complete seems to re-activate by itself and starts working for a few seconds, not crucial but I thought I'd let you know.

cgascons avatar Nov 23 '20 08:11 cgascons

Correct me if I'm wrong, is the extension continuously re-compiling all the linked projects and libraries every time I edit code? In case it is, I believe that may be contributing to the issue and making the whole process slower.

cgascons avatar Nov 23 '20 15:11 cgascons

Funny thing though, if I leave the project long enough open after editing it, there's a moment where the intellisense auto-complete seems to re-activate by itself and starts working for a few seconds, not crucial but I thought I'd let you know.

Thanks. At least we can be sure that it's not stuck in an infinite loop somewhere.

Correct me if I'm wrong, is the extension continuously re-compiling all the linked projects and libraries every time I edit code? In case it is, I believe that may be contributing to the issue and making the whole process slower.

It's designed to recompile only what has changed. Only the class you are editing, and maybe some things that directly depend on the class. The problem with your project is that the extension is asking the compiler for a specific class in compiled form, and the compiler doesn't seem to have it. So it tries to recompile the whole project, which takes a long time. Then, it still can't find the class, so it keeps trying the same thing. To be clear, it should only need to do that once, so I'm trying to figure out what is making it fail repeatedly.

joshtynjala avatar Nov 23 '20 17:11 joshtynjala

Hi Josh, just wanted to let you know I haven't forgotten about this issue and as soon as I get the time I will create a test project to make it easier for you to replicate the error on your end, we are just finishing an expansion to be released next week and couldn't find the time to do it yet.

cgascons avatar Dec 02 '20 08:12 cgascons

Hi Josh.

I've been trying to create a sample project for you these last two days and I just can't seem to be able to replicate this issue on a test project.

I have some clues that might be interesting for you though.

The only way I experience this issue is by editing the custom engine we built for our trading card games, it's a quite big project, that's why I believe it's being so difficult to replicate creating small sample projects. I have tried testing by downloading big open source projects without luck.

I have installed the VSCodeCounter extension to check how large is the project in class and lines amount and (just in case it helps) it's 676 classes summing up 338.434 lines of code.

Still, I don't believe it's just the lines of code or the amount of classes, but how it's structured internally. Please let me know if this makes sense: in our current project we have a class called the InstanceMng. This class basically has references to all classes in game, i.e. we use it to get instances of all our managers. Each Manager class has lots of references (imports) to the more (small) classes so I'm kind of seeing here a tree structure here. Could the issue here is that the plugin is somehow recursively looping through these classes if they are connected (have imports to each other)? I know this may sound weird but it's as far as I could get. Perhaps you have access to a very large project that has a similar structure?

cgascons avatar Dec 16 '20 10:12 cgascons

I don't think that it has anything to do with how your code depends on other classes or imports things. I think it is related to how your project or workspace is configured in some way.

I have one especially large workspace with 4 apps and 6 library projects that is probably comparable in terms of number of classes, but I have not been able to reproduce this issue with that one.

A couple of things to try:

  1. Have you tried increasing the memory used by the extension with the as3mxml.languageServer.jvmargs setting? Since it's a large project, more memory may help. I think Java chooses a default size based on your computer specs, so I don't know what the default is. It's the -Xmx arg. Maybe try -Xmx1024m or -Xmx2048m.

  2. In the latest update, I added the as3mxml.languageServer.concurrentRequests setting. Can you try changing this to false? Then, close and restart VSCode. If this helps, we can be sure that this is a multi-threading issue. If not, then we can rule that out.

joshtynjala avatar Dec 16 '20 16:12 joshtynjala

Hi Josh, I'm afraid none of the two suggestions you mentioned worked for me. I even tried increasing the memory to 4096 without luck.

On a side note, I'm sensing like every key I type on the keyboard while in vscode attempts to search for errors and makes me think it's also affecting the whole thing, is that possible? I have made a video (and a gif) for you showing just that in case it helps, it's 44 seconds long, if you watch it, notice that around second 20 it starts checking character by character and updating the problems window:

vscode Video.mov.zip

cgascons avatar Dec 17 '20 08:12 cgascons

Hey Josh, first of all Merry Christmas! Just wanted to update you letting you know that, this week since I'm working from home I'm lo longer using a Mac and I'm on a quite powerful PC and still having issues with this, to the point of having to restart the PC from time to time. So basically wanted to check in to see if you made any progress or you need me to do anything else besides my last post here. Just ask if you need me to do anything.

cgascons avatar Dec 29 '20 15:12 cgascons

I still need someone to share a project that can reproduce the issue on one of my computers. Until that happens, I'm stuck.

joshtynjala avatar Dec 31 '20 21:12 joshtynjala

I understand Josh, I will keep trying from time to time and will post here if I'm ever capable of creating a fully replicable project. Thanks!

cgascons avatar Jan 07 '21 08:01 cgascons

Hi, I've got some extra information about this. I recently updated my MacOS to Big Sur, checked to see if this issue was still present and it was. After a few days playing around with the OS I created a backup of all my repos and performed a clean re-install of Big Sur from scratch to check step by step until finding the issue.

After installing VSCode and your extension I was able to open the project. At this point there was no Java installed at all. your extension warned me about that with the following message:

Could not locate valid Java executable. To configure Java manually, use the as3mxml.java.path setting.

I ignored it and moved on to see if at least the intellisense would work and it kind of did actually. No delays there. I was able to reference any class of the project right away, I should say that once I referenced a class, the extension could not access the functions and variables inside it and intellisense always prompted me with the functions and variables of the class I was referencing it from, but at least it wasn't lagging at that point.

That said, I am suspecting this has something to do perhaps with Java version? I'm using a very old (1024-RSA) certificate created back in 2012 which forces me to use Java version 1.8.0_112, which is the latest that allows me to compile that certificate for our Android and Steam version of the game. I have not tried to install a newer version of Java and check if the error persists but I just thought this info would be useful.

Perhaps @jnpatrick99 from #420 could confirm if he's also using an old Java version?

[Edit] After installing both Java JDK and JRE (v1.8.0_122) in the computer Visual Studio started to be laggy like before the update.

cgascons avatar Jan 22 '21 10:01 cgascons

the extension could not access the functions and variables inside it and intellisense always prompted me with the functions and variables of the class I was referencing it from

I think that this is VSCode's default IntelliSense, which literally just suggests strings from the same file and has zero understanding of the code. If vscode-as3mxml is complaining about not finding Java, then it hasn't even started up yet.

joshtynjala avatar Jan 22 '21 17:01 joshtynjala

Hello, I am experiencing a very similar problem to the one posted here at the beginning. Intellisense only works for me for a few seconds, or "that's what it seems like"? I share it in case you can give a new clue for explanation and/or resolution:

It really "only works for a few seconds" is an "illusion". In my case, Intellisense works for me "until I open some of the files of a library I am assembling". After opening one of them, Intellisense does not work again and the typical tooltip "loading..." appears.

In my case, it is not a big project but a small one [1], a royale example project in which I am collaborating.

It doesn't happen to me in any other project, for now. Although I think the error comes from the project itself or wk, I have tried different configurations of JAVA_TOOL_OPTIONS and as3mxml.languageServer.jvmargs but none has changed the result. I am using java 1.8.0_291 of 64

Have you found out anything during this time?

Thx. Hiedra

mjesteve avatar Jun 07 '21 00:06 mjesteve

Hi mjesteve, We have not found any workarounds as of yet, the issue keeps happening every day but there's no way we can manage to create a replicable sample project for Josh to try it out so looks like this one's going to be a hard one to tackle.

cgascons avatar Jun 07 '21 07:06 cgascons

Hello cgascons, in my project yes it can be replicated and it is small. It is in a public repo, maybe Josh can replicate it with it. Hopefully because programming like that is "somewhat complicated". If you had some time, maybe, you could try it yourself and confirm that it replicates the behavior in your system, could it be?

Hiedra.

mjesteve avatar Jun 07 '21 07:06 mjesteve

If you had some time, maybe, you could try it yourself and confirm that it replicates the behavior in your system, could it be?

I'll definitely will give it a try as soon as possible, thanks for sharing

cgascons avatar Jun 07 '21 07:06 cgascons

It would be great. Thank you.

mjesteve avatar Jun 07 '21 08:06 mjesteve

@mjesteve Thanks for sharing a project! Hopefully, that will allow me to reproduce the issue. I'll let you know.

joshtynjala avatar Jun 07 '21 15:06 joshtynjala

After opening one of them, Intellisense does not work again and the typical tooltip "loading..." appears.

@mjesteve Is there a particular file that you open where it causes the issue to reproduce consistently? I did some quick tests, and unfortunately, everything seems to be working correctly on my computer.

I am not using custom values for either JAVA_TOOL_OPTIONS or as3mxml.languageServer.jvmargs. JDK 1.8.0_282 (64-bit).

joshtynjala avatar Jun 07 '21 16:06 joshtynjala

Hi Josh, thx. In case it is useful I leave here my wk file : (royale-examples-community.code-workspace)

{
	"folders": [
        {
            "path": "royale-examples-community"
        },
        {
            "path": "royale-examples-community\\royaleapp\\royalejewel"
        },
        {
            "path": "royale-examples-community\\royalelibs"
        },
        {
            "path": "..\\Royale-SDK\\royale-asjs-fork\\frameworks\\projects"
        }
    ],
    "settings": {
        "as3mxml.sdk.framework": "D:\\Develop_Royale\\Projects\\Royale-SDK\\royale-asjs-fork",
        "as3mxml.sdk.editor": "D:\\Develop_Royale\\Projects\\Royale-SDK\\royale-asjs-fork"
    }
}

I have included the SDK "projects" folder for convenient debugging (actually I have it in all wk files without causing any complications other than a "warning" because the asconfig.json version specifies a deprecated 1.1 version).

I just received your last email... I attach a gif "they say a picture is worth 1000 words".

GIF 07-06-2021 18-23-51

Can you reproduce it? JsCalendarViewYear.mxml is in the sample project and "AnnualJSCalendar.mxml" in the library. (Maybe there are errors Josh, I'm working with this control :) )

mjesteve avatar Jun 07 '21 16:06 mjesteve