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

MvxSetupSingleton optimizations / Fix SplashScreen initialization on Android #2746

Merged
merged 7 commits into from
Apr 2, 2018

Conversation

nmilcoff
Copy link
Contributor

@nmilcoff nmilcoff commented Mar 30, 2018

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Bug fix

⤵️ What is the current behavior?

  1. Starting from SplashScreen doesn't work on Android
  2. Setup is called multiple times during Android startup

🆕 What is the new behavior (if this is a feature change)?

Above is fixed, also made some optimizations and added some reference comments to MvxSetupSingleton.

💥 Does this PR introduce a breaking change?

Yes. TriggerFirstNavigate was removed.

🐛 Recommendations for testing

Test the Playground apps

📝 Links to relevant issues/docs

PR: #2713

🤔 Checklist before submitting

@nmilcoff nmilcoff added this to the 6.0.0 milestone Mar 30, 2018
Copy link
Contributor

@kjeremy kjeremy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see this split into two commits: one with the fix and the other with the optimizations (ie do not squash so the fix stands out).

@nmilcoff
Copy link
Contributor Author

@kjeremy 👍 ! It's splitted now

{
public SplashScreen()
: base(Resource.Layout.SplashScreen)
{
}

protected override void OnResume()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this override need to be here?

Copy link
Contributor

@nickrandolph nickrandolph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnsureInitialized MUST guarrantee that Initialize (both primary and secondary) has completed before returning - current implementation of all platforms relies on this.

}
else
{
MvxLog.Instance.Trace("EnsureInitialized has already been called so now waiting for completion");
StartSetupInitialization();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This beaks the behaviour of EnsureInitialized which should block until setup is completed. Currently this PR breaks more than it fixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable. We need to test PRs like #2713 or this one more before merging...

@@ -86,5 +85,10 @@ protected virtual void TriggerFirstNavigate()
if (!startup.IsStarted)
startup.Start();
}

// do nothing on this override, as initial navigation is managed by TriggerFirstNavigate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove TriggerFirstNavigate?

@nmilcoff
Copy link
Contributor Author

nmilcoff commented Mar 31, 2018

Ok guys, thank you all for your feedback! Honestly I feel like this PR is actually fixing some issues that were introduced just before... We need to be more careful with merging.

You'll notice I removed some calls to EnsureInitialized. This is because all Android Activities are already calling that here (that method is called from OnCreate).

@nmilcoff nmilcoff dismissed stale reviews from kjeremy and nickrandolph March 31, 2018 03:52

Changes were applied

@nickrandolph
Copy link
Contributor

I think this is probably one of the more complex parts of mvx to get right. Mainly because each platform has slightly different startup behaviour and we’re trying to coerce into a single pattern to make it easy for devs.
I don’t think we’re quite there as there are still some race conditions with the latest edits but we’re getting there. I think it’s be good to have some tests around this, so I will try and get that started when I have some time.

martijn00
martijn00 previously approved these changes Mar 31, 2018
@kjeremy
Copy link
Contributor

kjeremy commented Mar 31, 2018 via email

@nickrandolph
Copy link
Contributor

@martijn00 @nmilcoff I've done another pass through this PR and whilst there are some extreme edge cases where a race condition can occur, they're not easily resolvable without reworking the singleton significantly. I propose that this PR is accepted as is, and that we confirm that all platforms (inc Forms) are working well on startup.

@martijn00 martijn00 merged commit e37c07f into MvvmCross:develop Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants