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

onInflate() onInflate() crash #59

Closed
ghost opened this issue Mar 27, 2014 · 2 comments · Fixed by #60
Closed

onInflate() onInflate() crash #59

ghost opened this issue Mar 27, 2014 · 2 comments · Fixed by #60
Labels

Comments

@ghost
Copy link

ghost commented Mar 27, 2014

We have an exciting family of crashes where:

  • view inflation starts and lots of views are inflated, their presenters' takeView
    and onLoad methods are called
  • Android senses a configuration change and never attaches those views
    • so their onDetachedFromWindow methods are not called
    • so their Presenters' dropView methods are not called
  • the outgoing activity does call dropView for its own presenters
  • A new activity starts, finds the existing activity scope and calls its onCreate method,
    before it calls takeView on its own presenters
    • it tells previously registered bundlers to onLoad
    • some of them are in presenters that still have views from the old config, so
      they go ahead and call presenter onLoad

So now we have child presenters trying to load, and possibly asking their ancestor presenters to do stuff while the ancestors' views are still null. Crashes ensue.

@dnkoutso and I are pretty certain that the fix is simple: make presenters debounce their onLoad calls. It's already the case that Presenter#onLoad will not be called until takeView has been received. We should go further and make certain that onLoad will be called exactly once for any View instance.

We haven't thought yet of anything that this will break, and can think of lots of things that it will fix.

@ghost ghost added the bug label Mar 27, 2014
@ghost
Copy link
Author

ghost commented Mar 27, 2014

PR forthcoming

ghost pushed a commit that referenced this issue Mar 27, 2014
@ghost ghost mentioned this issue Mar 27, 2014
@ghost ghost closed this as completed in #60 Mar 28, 2014
@LukeStClair
Copy link

This also has the beneficial effect of making it much easier to work with observables - I was getting double subscribes in onLoad, which was quite surprising and leads to interesting side effects.

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

Successfully merging a pull request may close this issue.

1 participant