sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
803 stars 39 forks source link

ST hangs during file search - Discord Rich Presence #6459

Closed jaraco closed 2 weeks ago

jaraco commented 3 weeks ago

Description of the bug

As reported in tech support 73201, ST hangs when preview-opening files during a file search.

I'm reporting the issue here also, as it now appears to be more of a bug than a support issue.

Steps to reproduce

  1. Install Sublime Text 4180
  2. Install Package Control
  3. Install LSP-ruff
  4. Copy some non-trivial Python files to a directory (something like http --follow https://github.com/python/cpython/archive/refs/tags/v3.12.5.zip | bsdtar -x cpython-3.12.5/Lib/*.py)
  5. Open that directory (subl cpython-3.12.5/Lib)
  6. Use Cmd+P and scroll up and down the list until the application hangs

Expected behavior

Sublime Text should avoid race conditions and be resilient to race conditions in plugins.

Actual behavior

The app hangs.

Sublime Text build number

4180

Operating system & version

macOS 14.6.1

(Linux) Desktop environment and/or window manager

No response

Additional information

No response

OpenGL context information

No response

rchl commented 3 weeks ago

Following up in https://github.com/sublimelsp/LSP-ruff/issues/75 since this is likely not an ST issue.

jaraco commented 2 weeks ago

I've since found that the issue indeed replicates with all plugins disabled (and ST restarted):

https://dl.dropboxusercontent.com/scl/fi/yntlej07oz1x7w3tqanbb/Screen-Recording-2024-08-23-at-15.02.56.mov?rlkey=b4i8vydpso4q321uxfjo1ra0r

So LSP-ruff is no longer implicated.

Yet, if I start in safe mode, I can scroll up and down all day long with no hangs.

I'm now beginning to think the issue might be related to how I have the User directory stored in Dropbox:

 Sublime Text 🐚 pwd
/Users/jaraco/Library/Application Support/Sublime Text
 Sublime Text 🐚 ls -la Packages
total 0
drwx------   5 jaraco  staff  160 Aug 21 10:44 .
drwx------  10 jaraco  staff  320 Mar 14 16:52 ..
drwxr-xr-x  12 jaraco  staff  384 Mar 25 20:51 AutoSpell
drwxr-xr-x   3 jaraco  staff   96 Aug 21 10:44 SublimeLinter-mypy
lrwxr-xr-x@  1 jaraco  staff   57 Feb  9  2024 User -> /Users/jaraco/Dropbox/AppData/Sublime Text/Packages/User/

I do that so I can take my settings with me and don't have to maintain configurations on machines separately.

jaraco commented 2 weeks ago

I'm now beginning to think the issue might be related to how I have the User directory stored in Dropbox:

No, it's not that. I removed the symlink and replaced it with a copy of the files, but the issue still occurs.

jaraco commented 2 weeks ago

At this stage, I think I'm going to rebuild my profile from scratch incrementally and check the issue periodically through the process. Still, I'd appreciate any insight on what sorts of things might cause ST to hang when scanning through files when all plugins are disabled.

BenjaminSchaaf commented 2 weeks ago

Closing this according to the comment in https://github.com/sublimelsp/LSP-ruff/issues/75

jaraco commented 2 weeks ago

Please re-open. The issue persists. I've excluded LSP-ruff as the cause, but the issue still exists and I'm still investigating the cause. I'm hoping to rebuild my profile from scratch, but it takes time and I haven't had the time yet. I'm still getting crashes several times a day (on my original profile).

jaraco commented 2 weeks ago

Okay. I think I've solved the problem.

First, it helped to have a reliable reproducer. Trying to type and delete characters until the issue occurred was tedious and error-prone. Once I found that simply holding the down button to scroll through hundreds of files would readily reproduce the issue, it became easier to diagnose.

Second, I thought I was disabling packages when I wasn't. I had added a ignore_packages field to my Package Control.sublime-settings, but it was having no effect, because the setting needs to be in Preferences.sublime-settings (possibly because there's already an ignore_packages settings in that file). I was able to find the correct file by using the "Disable Package" action and seeing what file it changed.

I was then able to bisect the packages once again and using the reliable reproducer determine which subsets of packages triggered the issue.

It turns out the offending package is Discord Rich Presence, which I'd installed recently (around the same time as I upgraded to Sublime Text 4080). That explains why I thought it was the upgrade and why downgrading did not help (although I thought at first it did). When I installed that package, I didn't think too much about it.

Disabling that package, I can scroll up and down any project without any hangs.

I'll report the issue with that project.