-
Notifications
You must be signed in to change notification settings - Fork 18k
x/mobile/app: app.State is nil in package init #10031
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
// State is global application-specific state. 2015-02-27 14:38 GMT-05:00 Burcu Dogan notifications@github.com:
__ |
But we know about the current VM and the application context on JNI_Onload. We don't have to wait for app.Run to set the State. |
We do in Java. I intended State to eventually provide access to some equivalent context on the iOS side, where the initialization order is reversed: Go is the entry point, init runs, then main starts and it is not until app.Run that we initialize UIKit. The other less important but relevant thought I had on this is packages should work hard to minimize the init work they do in apps. Apps should start fast. I suspect initialization of almost all packages (including audio) should go into an internal sync.Once on first use. |
We can keep documenting that the State will be available after app.Run but can set the State resolver earlier and use these values internally if the init is fast enough and not affecting the startup performance. It is an internal implementation detail. If you fear that it will be abused by the users, I'm fine with doing to a sync.Once for the initialization of the audio package. |
In favor of accessing app.State after Run is invoked, I am closing the issue. |
My Android application panics with the following error message, if I try to access app.State from a package's init.
The package causes the panic does the following:
The text was updated successfully, but these errors were encountered: