-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Crash on open when previous position was on a now-disconnected display #3695
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
Comments
Hello from another IINA user, When an application crashes macOS usually creates a crash report. If the crash happened recently the report may still be available. Open With computers there is a vast amount of complexity going on "under the hood". The computer industry works hard to hide this from users. But when a failure occurs. it is frequently necessary to dig into all the behind the scenes details to fully understand and correct the root cause of the problem. With respect to crashes, the crash report is a critical piece of evidence and required for diagnosing the problem. |
Apologies, I hoped that someone who had worked in the area may have quickly recognised this as an unhandled case or something. Here is the latest crash report:
|
No need to apologize. I'm happy when people take the time to report problems. Thanks for posting the crash report. The crash report shows the crash occurred here:
Something in this code failed: func windowWillOpen() {
var screen = window!.screen!
if let rectString = UserDefaults.standard.value(forKey: "MainWindowLastPosition") as? String {
let rect = NSRectFromString(rectString)
if let lastScreen = NSScreen.screens.first(where: { NSPointInRect(rect.origin, $0.visibleFrame) }) {
screen = lastScreen
}
}
if shouldApplyInitialWindowSize, let wfg = windowFrameFromGeometry(newSize: AppData.sizeWhenNoVideo, screen: screen) {
window!.setFrame(wfg, display: true)
} else {
window!.setFrame(AppData.sizeWhenNoVideo.centeredRect(in: screen.visibleFrame), display: true)
}
videoView.videoLayer.draw(forced: true)
} Notice the reference to "MainWindowLastPosition" and the references to screens. This code is definitely involved in exactly what is described in your problem report, remembering the previous window position. I tried reproducing the crash. I didn't trigger a crash, but I definitely put IINA into a bad state:
Definitely something is broken in the code. I don't remember seeing an IINA issue with a similar crash. I do remember something about issues with multiple monitors. Late here, brain slowing down. I will try and find time to take another look at this tomorrow when I'm more awake. Although I'm just another IINA user I am a software engineer and have been investigating some IINA problems and submitting proposed fixes. I will see if I can figure out what is going on in this case. |
Reproduced crash. Continuing to investigate. |
The commit in the pull request will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
Reproducing
AnalysisIINA is crashing on the first statement in func windowWillOpen() {
var screen = window!.screen! Running in Xcode the console shows:
The documentation of the NSWindow.screen property says:
This explains the crash reported in the issue. Unfortunately while testing I encountered another problem. None of the IINA menus would respond after disconnecting the external monitor. These messages would pour out in Xcode console when touching the IINA menus:
I found this error being discussed in this post in the Apple Developer Forums: Sudden error being logged continuously in XCode console It is sounding like this is a regression added in macOS Monterey, maybe starting with 12.2. Troubling. FixingThe commit in the pull request will:
The new
If the screen associated with the window is Example of log messages testing the failing scenario:
Example of log messages when running on an external monitor:
|
@qtist Thanks again for reporting this problem! Definitely an important one to fix. |
This commit will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
No problem, great work @low-batt! |
This commit will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
This commit will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
This commit will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
This commit will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
This commit will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
This commit will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
The commit in the pull request will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
Rebased and corrected merge conflicts and addressed review comments. The commit in the pull request will: - Add a new method selectDefaultScreen to Extensions.NSWindow that selects the screen to use as the default for a window - Add a new method log to Extensions.NSScreen for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
This commit will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
* Fix crash on open when external display disconnected, #3695 The commit in the pull request will: - Add a new method selectDefaultScreen to MainWindowController that selects the screen to use as the default for a window - Add a new method logScreen to MainWindowController for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen. * Fix crash on open when external display disconnected, #3695 Rebased and corrected merge conflicts and addressed review comments. The commit in the pull request will: - Add a new method selectDefaultScreen to Extensions.NSWindow that selects the screen to use as the default for a window - Add a new method log to Extensions.NSScreen for screen related log messages - Change windowWillOpen to log information about screen selection - Change windowWillOpen to use selectDefaultScreen The new selectDefaultScreen method searches for a screen in this order: - window!.screen: The screen where most of the window is on; it is nil when the window is offscreen. - NSScreen.main: The screen containing the window that is currently receiving keyboard events. - NSScreeen.screens[0]: The primary screen of the user’s system. If the screen associated with the window is nil this method will fall back to using the main screen. Apple documentation is silent concerning when NSScreen.main is nil. If that is encountered the method will fall back to using the primary screen.
The fix in PR #3698 has been merged into the develop branch. |
Closing. Fixed in IINA 1.3.0. |
IINA generally lives on my secondary display. After using it in this state, when only one display is connected and I try to open a video, IINA will consistently crash every time (as if it tries to resume into a position that no longer exists). I must have done this 100 times now and keep forgetting to expect it. Recovery is simply opening the file again and it works as normal.
The text was updated successfully, but these errors were encountered: