-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MaxPane can crash SublimeText #1785
Comments
are you able to provide an example that doesn't require MaxPane to be installed, just to make it clearer what is happening/where it is crashing? i.e. a specific combination of |
I have a layout with two groups which window.get_layout() returns By calling MaxPane while left pane is active, the layout is changed to: I guess this means it just sets the maximized column/row to maximum relative width/height. The maximized left group contains 3 views/documents. Pressing Ctrl+K, Ctrlk+Up immediately crashes Sublime Text. Running Doing the same thing with right group maximized causes both keybinding and running "new_pane" from console to crash the very first time. I guess the width/height of 0.0 of the "hidden" views causes some layout calculation to fail maybe with division by 0? |
This is almost certainly caused by the same thing as #961 |
@keith-hall, I managed to create a minimal example by exhaustively testing MaxPane code.
It instantaneously creates a dump file with the following: ae9e693d-13ca-484a-ae72-9b150d059cfd.zip
Environment
@deathaxe, while searching for the cause of the crashed, I figured out you can fix the MaxPane package by changing these lines: w.set_layout(l)
w.set_layout(PaneManager.popLayout(w))
w.set_layout(l)
# -->
sublime.set_timeout( lambda: w.set_layout(l), 100 )
layout = PaneManager.popLayout(w)
sublime.set_timeout( lambda: w.set_layout( layout ), 100 )
sublime.set_timeout( lambda: w.set_layout(l), 100 ) @wbond, the crash itself happens because MaxPane is trying to change the layout by the When the layout is maximized, i.e., with the state:
And we call the Adding the delay fixes the crash problem because now Sublime Text is not trying to change the layout twice in row and inside the I tried adding a delay of 0 instead of 100 milliseconds, but when I tested, if I try to randomly keep maximizing panes and changing layouts highly often/fast, Sublime Text still crashing some random times, not easily reproducible. |
Great investigation. Can reproduce the crash with your example. Very helpfull. But can't find the lines to change in max_pane.py in the current upstream master though. But nevertheless your minimal example stops crashing if we use class MaxPaneEvents(sublime_plugin.EventListener):
def on_activated_async(self, view):
w = view.window()
w.set_layout({'rows': [0.0, 1.0], 'cols': [0.0, 0.5, 1.0], 'cells': [[0, 0, 1, 1], [1, 0, 2, 1]]}) If we don't like the flickering caused by the asynchronous event listener and in order to keep compatibility with ST2, the following fix works as well class MaxPaneEvents(sublime_plugin.EventListener):
def on_activated(self, view):
def worker():
w = view.window()
w.set_layout({'rows': [0.0, 1.0], 'cols': [0.0, 0.5, 1.0], 'cells': [[0, 0, 1, 1], [1, 0, 2, 1]]})
sublime.set_timeout(worker) Package Control and other plugins which used to work for ST2 use |
Sublime Text can crash on certain layout changes, especially if another layout change is still on the fly. see: sublimehq/sublime_text#1785 This commit queues/delays the execution of the code in the `on_activated()` handler to ensure the ST core can finish a layout change before calling the next one. A synchronous `set_timeout()` is used for backward compatibility with ST2 and because of no flickering when manipulating the layout. The 10ms delay is also added for backward compatibility reasons and is not needed for recent ST3 builds. The `view` is passed using the `partial()` function to ensure the queued worker uses the correct and valid instance. Note: The event handlers don't need to return a value like `None`.
Sublime Text can crash on certain layout changes, especially if another layout change is still on the fly. see: sublimehq/sublime_text#1785 This commit queues/delays the execution of the code in the `on_activated()` handler to ensure the ST core can finish a layout change before calling the next one. A synchronous `set_timeout()` is used for backward compatibility with ST2 and because of no flickering when manipulating the layout. The 10ms delay is also added for backward compatibility reasons and is not needed for recent ST3 builds. The `view` is passed using the `partial()` function to ensure the queued worker uses the correct and valid instance. Note: The event handlers don't need to return a value like `None`. Fix partial doesn't work The on_activated() is not called if partial() is used in the decorator. Hence, remove it. Fix on_window_command Queue `on_window_command` the same way as `on_activate` causes strange things to happen. Revert it. Simplify decorator The decorator's only job is to run a function delayed.
Updated MaxPane for various reasons recently, including ...
Not sure whether it helps fixing occational crashes, but hope it makes things better. |
I did the same things as you, except I kept using |
Haven't seen crashs using MaxPane anymore. Can't repreoduce this issue using the minimal examples in ST4 anymore. |
Summary
I often use MaxPane package to temporarily maximize a view in a multi group layout. Stupid but sometimes I forget a view is maximized and try to push a file to a second pane. This is the time Sublime Text reminds me about the maximized pane by crashing. It suddenly exists.
The issue was reported in 2014 at jisaacks/MaxPane#10
Expected behavior
Sublime Text may display a error message if something prevents it from creating a new pane and abort the
new_pane
command, but it should not crash.Actual behavior
Sublime Text crashes and exits.
Steps to reproduce
new_pane
)or
Environment
dpi_scale
used in ST 1.0The text was updated successfully, but these errors were encountered: