Title: @EBean(SINGLETON) and getInstance_(Context) on BackgroundThread · Issue #1507 · androidannotations/androidannotations · GitHub
Open Graph Title: @EBean(SINGLETON) and getInstance_(Context) on BackgroundThread · Issue #1507 · androidannotations/androidannotations
X Title: @EBean(SINGLETON) and getInstance_(Context) on BackgroundThread · Issue #1507 · androidannotations/androidannotations
Description: When an Activity uses a @Bean that it initializes in a background Thread (afaik, there is no other way to avoid just showing the background until after initialization), the code for initializing the bean is not thread safe, and can cause...
Open Graph Description: When an Activity uses a @Bean that it initializes in a background Thread (afaik, there is no other way to avoid just showing the background until after initialization), the code for initializing th...
X Description: When an Activity uses a @Bean that it initializes in a background Thread (afaik, there is no other way to avoid just showing the background until after initialization), the code for initializing th...
Opengraph URL: https://github.com/androidannotations/androidannotations/issues/1507
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@EBean(SINGLETON) and getInstance_(Context) on BackgroundThread","articleBody":"When an Activity uses a `@Bean` that it initializes in a background Thread (afaik, there is no other way to avoid just showing the background until after initialization), the code for initializing the bean is not thread safe, and can cause (and for me, causes) Exceptions because the instance exists, but has not received a state yet.\n\nThe following is a typical getInstance_() method:\n\n``` java\n public static Client_ getInstance_(Context context) {\n if (instance_ == null) {\n OnViewChangedNotifier previousNotifier = OnViewChangedNotifier.replaceNotifier(null);\n instance_ = new Client_(context.getApplicationContext());\n instance_.init_();\n OnViewChangedNotifier.replaceNotifier(previousNotifier);\n }\n return instance_;\n }\n```\n\nWhat happens for me is that `instance_ = new Client()` has been run and completed, but not `instance_.init()`. This happens when e.g. the user rotates the screen causing a new BackgroundThread to be started.\n\nI managed to hack around the delay by using `@UiThread(propagation = ENQUEUE)` and `getInstance_(Context)`, but I would rather not have to do all initialization of all beans on the MainThread (for performance reasons).\n","author":{"url":"https://github.com/tobias-","@type":"Person","name":"tobias-"},"datePublished":"2015-07-30T15:22:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/1507/androidannotations/issues/1507"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:db7ffbf1-6e8c-8ca3-1675-64b29d3c2241 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B16C:3DA71:2D2BDE:3D78B8:6A61378F |
| html-safe-nonce | bc251f144b3ade9f424774572b737ab3f2466a767bfc516dd140fb4affa19bfe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTZDOjNEQTcxOjJEMkJERTozRDc4Qjg6NkE2MTM3OEYiLCJ2aXNpdG9yX2lkIjoiNTg1MTg3MTkxNDQyNDg3NDg5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7293da82e482ae7096624cb5ae375de54f6e2ccf4b0d6c947b216a3dd09e3082 |
| hovercard-subject-tag | issue:98196363 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/androidannotations/androidannotations/1507/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8063fad639a10b5dd1828da8830b797e0b5bfacdeb3f2efcf374f6574e39a218/androidannotations/androidannotations/issues/1507 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8063fad639a10b5dd1828da8830b797e0b5bfacdeb3f2efcf374f6574e39a218/androidannotations/androidannotations/issues/1507 |
| og:image:alt | When an Activity uses a @Bean that it initializes in a background Thread (afaik, there is no other way to avoid just showing the background until after initialization), the code for initializing th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tobias- |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b7a3d1e6770dc7153450d820fcfe9a7851c4cf2251dcc29c7ad3c5cd1b9e88b |
| turbo-cache-control | no-preview |
| go-import | github.com/androidannotations/androidannotations git https://github.com/androidannotations/androidannotations.git |
| octolytics-dimension-user_id | 1315313 |
| octolytics-dimension-user_login | androidannotations |
| octolytics-dimension-repository_id | 3116751 |
| octolytics-dimension-repository_nwo | androidannotations/androidannotations |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3116751 |
| octolytics-dimension-repository_network_root_nwo | androidannotations/androidannotations |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 78cf9d43f120d1f03636ca22ab420bcbb1712804 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width