I know the steps to reproduce the bug that the program lost its response

SyntaxEditor for Windows Forms Forum

Posted 2 years ago by hehui - manager, foxtable
Version: 22.1.0
Platform: .NET 4.0
Environment: Windows 10 (64-bit)
Avatar

Hello.

This is a piece of code in my program:

If AmbientParseRequestDispatcherProvider.Dispatcher Is Nothing Then
    AmbientParseRequestDispatcherProvider.Dispatcher = New Implementation.ThreadedParseRequestDispatcher()
    Dim appDataPath As String = IO.Path.Combine(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Code2"), "Repository")
    AmbientAssemblyRepositoryProvider.Repository = New Implementation.FileBasedAssemblyRepository(appDataPath)
End If

Now, just delete all files in the cache directory of appdatapath, or delete this directory, and then start my program. For the first time, enter:

Dim i As a

Once you enter a, the program loses its response.

Then starting the program for the second time, it returns to normal.

[Modified 2 years ago]

Comments (8)

Posted 2 years ago by hehui - manager, foxtable
Avatar

Important finding:

if you starting the program, and do not enter the code until all "*. Reflection. Dat" files are created, this bug will not occur.

Maybe it's because my program references a lot of library files and takes some more time to generate cache files, so it's easier for me to find this bug.

[Modified 2 years ago]

Posted 2 years ago by hehui - manager, foxtable
Avatar

This bug will still happen after the first time because there are still some cache files that have not been generated. As more and more cache files are generated, this bug will gradually disappear.

[Modified 2 years ago]

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Based on what you are describing, it sounds like the reflection cache data might be loading in your main UI thread.  And perhaps that processing is preventing the UI from being responsive while it executes?  

Have you used a technique like in our main demo where we have a BackgroundWorker that loads the assembly references?  That helps by offloading the work into a separate thread, which should prevent a main UI thread freeze.

Please make sure that you follow all of the steps in the Getting Started documentation topic since that walks through techniques like the use of BackgroundWorker that should make sure things perform well.


Actipro Software Support

Posted 2 years ago by hehui - manager, foxtable
Avatar

I developed it according to the official documents and examples, and this is the code:

Friend Sub InitializeSyntaxEditor()
	If AmbientParseRequestDispatcherProvider.Dispatcher Is Nothing Then
		AmbientParseRequestDispatcherProvider.Dispatcher = New Implementation.ThreadedParseRequestDispatcher()
		Dim appDataPath As String = IO.Path.Combine(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Foxtable CodeStudio"), "Assembly Repository")
		AmbientAssemblyRepositoryProvider.Repository = New Implementation.FileBasedAssemblyRepository(appDataPath)
	End If

	Me.AreIndentationGuidesVisible = True
	Me.AreMultipleSelectionRangesEnabled = False
	Me.IsLineNumberMarginVisible = True
	Me.CanCutCopyDragWithHtml = True
	Me.LineNumberMarginMinWidth = 24

	Dim language As New VBSyntaxLanguage()
	projectAssembly = language.GetService(Of IProjectAssembly)
	Dim assemblyLoader As New BackgroundWorker()
	AddHandler assemblyLoader.DoWork, AddressOf DotNetProjectAssemblyReferenceLoader
	assemblyLoader.RunWorkerAsync()

	Me.Document.Language = language
	Me.Document.FileName = Rand.NextString(10) & ".vb"

End Sub


Private Sub DotNetProjectAssemblyReferenceLoader(ByVal sender As Object, ByVal e As DoWorkEventArgs)
	projectAssembly.AssemblyReferences.AddMsCorLib()
	projectAssembly.AssemblyReferences.Add("System")
	For Each fl As String In SysInfo.referFiles.Split(New Char() {ControlChars.Lf, ControlChars.Cr }, System.StringSplitOptions.RemoveEmptyEntries)
		fl = IO.Path.GetFileNameWithoutExtension(fl)
		If projectAssembly.AssemblyReferences.Add(fl) Is Nothing Then
			projectAssembly.AssemblyReferences.Add(Assembly.LoadWithPartialName(fl))
		End If
	Next
End Sub

In addition, in order to solve the bug of with statement, I rewritten the "vbcompletionprovider" class. The code is:

Friend Class foxVBCompletionProvider
    Inherits VBCompletionProvider
    Public Overrides Function RequestSession(view As IEditorView, canCommitWithoutPopup As Boolean) As Boolean
       If WithStatement Then
           ''' other code
       Else
	   Return MyBase.RequestSession(view, canCommitWithoutPopup)
       End If
    End Function
End Class

When the "Return MyBase.RequestSession(view, canCommitWithoutPopup)" is executed, the program will lose the response.

In fact, if I do not follow the official document to design, when the reflection cache data be loading , other codes cannot be entered too.

In addition, once the program loses response, no matter how long you wait, it will not return to normal and will always be in a state of losing response

[Modified 2 years ago]

Posted 2 years ago by hehui - manager, foxtable
Avatar

I just found that , after the program lost its response, "*. reflection. dat" files was no longer generated, every thing is stoped

Posted 2 years ago by hehui - manager, foxtable
Avatar

I solved the problem temporarily:

Dim language As New VBSyntaxLanguage()
'projectAssembly = language.GetService(Of IProjectAssembly)
projectAssembly = New VBProjectAssembly("foxtable")
Dim assemblyLoader As New BackgroundWorker()
AddHandler assemblyLoader.RunWorkerCompleted, AddressOf assemblyLoader_RunWorkerCompleted
AddHandler assemblyLoader.DoWork, AddressOf DotNetProjectAssemblyReferenceLoader
assemblyLoader.RunWorkerAsync()
Private Sub DotNetProjectAssemblyReferenceLoader(ByVal sender As Object, ByVal e As DoWorkEventArgs)
   projectAssembly.AssemblyReferences.AddMsCorLib()
   projectAssembly.AssemblyReferences.Add("System")
   For Each fl As String In SysInfo.referFiles.Split(New Char() {ControlChars.Lf, ControlChars.Cr }, System.StringSplitOptions.RemoveEmptyEntries)
      fl = IO.Path.GetFileNameWithoutExtension(fl)
      If projectAssembly.AssemblyReferences.Add(fl) Is Nothing Then
         projectAssembly.AssemblyReferences.Add(Assembly.LoadWithPartialName(fl))
      End If
   Next
End Sub
Private Sub assemblyLoader_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
    Me.Document.Language.RegisterProjectAssembly(projectAssembly)
End Sub
Friend Class foxVBCompletionProvider
    Inherits VBCompletionProvider
    Public Overrides Function RequestSession(view As IEditorView, canCommitWithoutPopup As Boolean) As Boolean
       If WithStatement Then
           ''' other code
       Else
           Try
               Return MyBase.RequestSession(view, canCommitWithoutPopup)
           Catch ex As Exception
               Return False
           End Try
       End If
    End Function
End Class

The only regret is that when you input the code at the beginning, the content of the automatic completion list is incomplete, but it doesn't matter. It will be normal after a while.

[Modified 2 years ago]

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I'm not sure if you saw but v22.1.1 came out yesterday with some updates for the handling of With statements.  Does that update resolve the issue you are trying to work around with the custom completion provider?  If you still see that particular issue with v22.1.1 then please give us exact instructions to reproduce it in one of our samples.

As for the separate freeze issue, we have not really had reports of that.  Can you please make a new simple sample project that shows it happening so that we can debug with that and see what's happening?  Please send the sample to our support address, mentioning this thread, and exclude the bin/obj folders from the .zip you send so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 2 years ago by hehui - manager, foxtable
Avatar

The bug still exists in the new version,It's hard for me to provide an example.

But it doesn't matter. I'll just use the above method to solve it without affecting the use.

The old bug  about the with statement was handled in the new version, but it led to a new more serious bug. I explained it in another post. Please pay attention.

[Modified 2 years ago]

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.