Skip to content
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

Fixed crashing when forcefully unwrapping running application #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hahaSK
Copy link

@hahaSK hahaSK commented Oct 14, 2021

Hello again 👋,

I used asynchronous execution DispatchQueue.main.async and was getting crashes of forcefully unwrapping of running application so I have removed the unwrapping.

Also Swindler is missing the Appkit import.

@tmandry
Copy link
Owner

tmandry commented Oct 17, 2021

This means the application object won't be fully initialized. Can you elaborate on how you're using Swindler? Initialization already happens asynchronously, there's no need to do that explicitly, just use the future returned by initialize().

@hahaSK
Copy link
Author

hahaSK commented Oct 17, 2021

When my App starts it initialises Swindler and sets the handlers. Later there is a video playing full screen and while the video is playing windows/apps are positioned if necessary. But some app/s cause swindler to crash at that line of code. When I search for the PID that caused the crash (lazy var runningApplication: NSRunningApplication = NSRunningApplication(processIdentifier: self.processIdentifier)!) it is not in running processes -> cannot find the PID. So I think the problem is not caused by the asynchronous calls but by some application or the fact that the video is playing fullscreen while the windows/apps are being positioned. It is hard to find what is the cause of this problem because it happens only like 25% of time.
Also I checked the property and it is internal and only thing that uses it is property below lazy var bundleIdentifier: String? = self.runningApplication.bundleIdentifier which is already optional so no API changes required. Just one addition of ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants