Skip to content

Code completion stops returning results after running a Flutter app #2973

Closed

Description

@IsmailAlamKhan

After the app runs completely the dart analyzer is showing errors if I do something wrong but the snippets are not working but it gets fixed after restarting the dart analysis server. And if the dart analyzer is restarted while the app is compiling this issue doesn't occur. This issue mostly occurs in the stable channel of flutter.

Dart Code extension: 3.16.0
Flutter extension: 3.16.0 (activated)
Visual Studio Code Version: 1.51.1.

Activity

  1. DanTup commented on Dec 2, 2020

    @DanTup
    Member

    Do you mean you see "The Dart Analyzer has terminated" messages during builds?

    Can you confirm exactly what Flutter version you're on (run flutter --version)? Thanks!

  2. added
    awaiting infoRequires more information from the customer to progress
    on Dec 2, 2020
  3. IsmailAlamKhan commented on Dec 2, 2020

    @IsmailAlamKhan
    Author

    Flutter stable 1.22.4. I don't "The Dart Analyzer has terminated" message during builds but the snippets for flutter don't work also if I press the lamp to import the required library I don't see the library in the list also the wrap with widget is not there.

  4. DanTup commented on Dec 2, 2020

    @DanTup
    Member

    Can you provide an exact code sample/screenshot showing this so I can try to reproduce?

    Can you also confirm whether you have the "LSP Preview" setting enabled in VS Code/Dart settings? Thanks!

  5. IsmailAlamKhan commented on Dec 2, 2020

    @IsmailAlamKhan
    Author

    No, I don't have "LSP Preview" enabled. And here is a video showing the error
    Dart_Analyzer_Error.zip

  6. DanTup commented on Dec 2, 2020

    @DanTup
    Member

    @IsmailAlamKhan thanks for the video!

    A few questions/suggestions:

    • Does this reproduce on other projects, are only this one?
    • If just this ones, does your project have any code-generation in it?
    • If you click the Bell icon on the bottom right of the status bar, are there are any errors in there?
    • If you enable the LSP Preview setting and restart VS Code, does the issue go away?

    Thanks!

  7. IsmailAlamKhan commented on Dec 2, 2020

    @IsmailAlamKhan
    Author
    1. No this reproduces on every project.
    2. No answer.
    3. No.
    4. No.
  8. changed the title [-]Dart Analyzer "{"analysis":{"isAnalyzing":false}}" after running.[/-] [+]Code completion stops returning results after running a Flutter app[/+] on Dec 2, 2020
  9. DanTup commented on Dec 2, 2020

    @DanTup
    Member

    Could you try capturing a log for me to review using a small sample project and with LSP enabled? Use a small sample project because the log may include parts of source code, and the smaller project will produce a smaller log.

    • Enable the Preview LSP setting in VS Code
    • Create a simple app using flutter create and open it in VS Code
    • Run the Open Workspace Settings command in VS Code (note: workspace!)
    • Paste the following into the JSON:
      {
        "dart.analyzerInstrumentationLogFile": "logs/analyzer.instrum.txt"
      }
    • Reload VS Code with the Developer: Reload Window command
    • Reproduce the issue

    This should create a file at logs/analyzer.instrum.txt logging everything going on in the analysis server. This might get quite large, but you can paste it into a gist or zip it up and email it to me ([email protected]).

    Thanks!

  10. IsmailAlamKhan commented on Dec 2, 2020

    @IsmailAlamKhan
    Author

    I made a simple using flutter create and did all the things you told me. But I am not able to reproduce the issue there. This issue occurs when the project is big.

  11. IsmailAlamKhan commented on Dec 2, 2020

    @IsmailAlamKhan
    Author

    I checked with my other projects and I can reproduce it there.

  12. onaoura commented on Dec 2, 2020

    @onaoura

    I am facing same issue. Autocomplete is working fine before running the project. Once I run it, autocomplete stop working.

  13. DanTup commented on Dec 3, 2020

    @DanTup
    Member

    I made a simple using flutter create and did all the things you told me. But I am not able to reproduce the issue there. This issue occurs when the project is big.

    Are you able to create a project that triggers this problem that you can share?

    Otherwise, could you share:

    • The output of running code --status in a terminal after this has happened (but while VS Code is still open)
    • A copy of your pubspec.yaml
    • A copy of your pubspec.lock file

    Thanks!

  14. IsmailAlamKhan commented on Dec 3, 2020

    @IsmailAlamKhan
    Author

    I zipped the output of code --status and a copy of my pubspec.yaml and pubspec.lock code_status.zip

  15. 43 remaining items

  16. DanTup commented on Jan 12, 2021

    @DanTup
    Member

    @bwilkerson @scheglov I was able to fairly reliably reproduce this issue in a script which repeatedly spawns a Flutter app, stops it, deletes the build folder. After a number of times, completions no longer include any suggestion sets with them.

    I narrowed it down to occurring whenever the following is printed to the analysis server instrumentation log:

    1610465348830:Err:Watcher error; refreshing contexts.
    FileSystemException:: Directory watcher closed unexpectedly, path = 'M::\Dev\TestStuff\foo'
    #0      _FileSystemWatcher._listenOnSocket.<anonymous closure> (dart::io-patch/file_patch.dart::330::11)
    #1      _ExpandStream._handleData (dart::async/stream_pipe.dart::240::30)
    #2      _rootRunUnary (dart::async/zone.dart::1202::13)
    #3      _CustomZone.runUnary (dart::async/zone.dart::1097::19)
    #4      _CustomZone.runUnaryGuarded (dart::async/zone.dart::1002::7)
    #5      _BufferingStreamSubscription._sendData (dart::async/stream_impl.dart::357::11)
    #6      _BufferingStreamSubscription._add (dart::async/stream_impl.dart::285::7)
    #7      _SyncStreamControllerDispatch._sendData (dart::async/stream_controller.dart::807::19)
    #8      _StreamController._add (dart::async/stream_controller.dart::681::7)
    #9      _StreamController.add (dart::async/stream_controller.dart::624::5)
    #10     new _RawSocket.<anonymous closure> (dart::io-patch/socket_patch.dart::1683::35)
    #11     _NativeSocket.issueReadEvent.issue (dart::io-patch/socket_patch.dart::1181::18)
    #12     _microtaskLoop (dart::async/schedule_microtask.dart::41::21)
    #13     _startMicrotaskLoop (dart::async/schedule_microtask.dart::50::5)
    #14     _runPendingImmediateCallback (dart::isolate-patch/isolate_patch.dart::120::13)
    #15     _RawReceivePortImpl._handleMessage (dart::isolate-patch/isolate_patch.dart::185::5)
    

    After this occurs (handled here) calls to computeIncludedSetList get a null from tracker.getContext(analysisContext) which results in failing to add the completions here (which seems to be because the context is destroyed and/or recreated):

    https://github.com/dart-lang/sdk/blob/d63d5d93a59b370bf5f5c277109110cb67a96b75/pkg/analysis_server/lib/src/domains/completion/available_suggestions.dart#L24-L25

    If I trigger _handleWatchInterruption in code (for example by setting a timer to call it after 10 seconds in the ContextManagerImpl constructor), it reproduces reliably without needing to spawn Flutter or trigger lots of filesystem activity (presumably this will also happen on macOS).

  17. devoncarew commented on Jan 12, 2021

    @devoncarew
    Contributor

    @DanTup - thanks for the investigation and analysis! Can you create a corresponding issue in the dart-lang/sdk repo? I'd like to try and get a fix in for this for the next beta release.

  18. DanTup commented on Jan 12, 2021

    @DanTup
    Member

    @devoncarew I've filed dart-lang/sdk#44650. I'll close this this one as I don't think there's anything to do here.

  19. added and removed
    awaiting infoRequires more information from the customer to progress
    importantSomething important!
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Jan 12, 2021
  20. removed this from the v3.19.0 milestone on Jan 12, 2021
  21. added this to the v3.19.0 milestone on Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions