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

Storyboard / Runloop initialization race conditition #38

Open
vade opened this issue May 22, 2017 · 6 comments
Open

Storyboard / Runloop initialization race conditition #38

vade opened this issue May 22, 2017 · 6 comments
Assignees
Labels

Comments

@vade
Copy link
Member

vade commented May 22, 2017

Stupid bug, but @dlublin and I are working on a new Syphon enabled app, and on a View Controller View Did Load on a fresh OS X app with Storyboards, we could not get a SyphonServerDirectory to return any available servers.

Moving our Syphon Server Directory to app controller, Application Did Finish Launching makes it work, sans any other code changes

Speculation, but either an NSRunloop issue or some sort with NSDistributedNotifications aren't available / received in a timely fashion until App Did Finish Launching is fully completed.

Not so much a bug perhaps but a note of nuance.

Computers amirite?

@bangnoise
Copy link
Member

The SyphonServerDirectory never in its lifetime returns servers, or just in the vieDidLoad: method?

@vade
Copy link
Member Author

vade commented May 22, 2017

Sorry, should have been more clear - It never returned a dictionary of server descriptions due to run loop nuances. We were able to solve by calling a performSelector and putting the server directory one run loop 'tick' after viewDidLoad for the storyboard view controller being available.

basically.

app launch
view did load
application did finish launching

Having Server Description return available servers in view did load fails, you get an empty dict.

Waiting one run loop tick resolves the issue.

Requesting during app did finish launching works as well. Its only the first unarchiving, view did load of a Storyboard where it fails - which felt odd :)

@bangnoise
Copy link
Member

Still not sure what is being described here. If it is simply that early in its lifetime a SyphonServerDirectory doesn't return servers, then is that a bug?

We never want it to block waiting for responses from other applications, and you will have to deal with the arrival and disappearance of servers anyway through KVO or notifications, so it adds no extra work to the API user.

I could update the documentation for SyphonServerDirectory with a note saying that early in the application lifetime, -servers may not be populated..?

@vade
Copy link
Member Author

vade commented Oct 31, 2017

If I recall correctly, Its an initialization issue only with storyboards, where IIRC, -servers isnt just populated at application startup, but is never populated if you initialize within a storyboard view did load method.

Its nothing to do with SyphonServerDirectories lifetime, only when and where it is initialized, if a runloop isnt available registration for notifications or some other mechanism appears to fail and the object does not ever updated -servers.

Its similar to using Syphon on a thread w/o a run loop except you'd never expect it to happen in a Cocoa App whilst unarchiving / view did load (which works without storyboards last I looked).

@bangnoise
Copy link
Member

Ah, that is a bug. OK.

@bangnoise bangnoise self-assigned this Oct 31, 2017
@bangnoise bangnoise added the bug label Oct 31, 2017
@bangnoise
Copy link
Member

Here's a storyboard-based app where I can't reproduce the bug (SyphonServerDirectory returns servers). If you could modify it to reproduce the bug, I'll take a look at it.

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

No branches or pull requests

2 participants