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
x/mobile: do away with app.Main boilerplate #13988
Comments
And @nigeltao. |
The problem is OS X, where Cocoa wants to use the first thread acquired by the process for its event pump. If you have a way to make "go build" work on OS X without app.Main, let's remove it, but it is not a feature I want to lose. |
@crawshaw Is it just OS X, not also iOS? Could it be as simple as automatically injecting this file into the build?
|
@gordonklaus One potential flaw with that solution is runtime.LockOSThread is not recursive (at least currently). So if the main goroutine then calls some function that uses runtime.LockOSThread() + runtime.UnlockOSThread(), the OS thread will end up unlocked. |
@gordonklaus that's not enough, on OS X you need that code and you need to call |
@crawshaw I see. I think app.Main can still be avoided. It will just require some source manipulation, rewriting main.main. Maybe I'll take a crack at it tomorrow. Any advice is more than welcome 😄 |
The purpose of app.Main is to ensure that main.main runs on "the main thread" on certain platforms. Couldn't this also be achieved by having gomobile inject initialization code into the code it is compiling?
It's just a shame that every mobile app currently needs an extra level of indentation in func main. It adds unnecessary complexity, makes you wonder "what kinds of operations can I do in main vs in the app.Main callback?". It makes mobile apps feel like second-class citizens.
The text was updated successfully, but these errors were encountered: