-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix crash when switching back to the app after Permission change #3032
Fix crash when switching back to the app after Permission change #3032
Conversation
when changing permission and going back to the application, ViewAssemblies is null thus causes the app to crash during setup
Please can we address the issue of why ViewAssemblies is null - this is there as an optimisation so that that GetViewAssemblies (which could be an expensive call) doesn't have to be called repeatedly. |
When we have
|
I know this code was already there but the fallback to GetType().Assembly concerns me - it's less likely that this will resolve to the correct assembly now. It's no longer required to override Setup, which means that GetType().Assembly will resolve to the MVX assembly, rather than the application assembly |
I do have another suggestion which may require a bit of architecture change. How about making the splash screen just a splash screen with no setup needed and moving the setup to AppCompatActivity for which the code already exists. This way the whole starting the app from a different screen would make sense. However MvxIntentService issue won't be solved as setup.ensureinitialized still won't have the right assemblies |
No architecture change required. If you want you can use a vanilla splash screen today with mvx and just load mvx when you reach the first activity. But that defeats the whole point - which is to have splash shown whilst you setup mvx |
@vatsalyagoel do the repro steps in the description work with the Playground sample app? I'm concerned that ViewAssemblies is null as this shouldn't really happen |
Hi @nickrandolph I tested the issue in playground and it does happen there as well |
I tested this in one of my own apps, and can confirm that i both see the same issue, and that this fixes it. I'm not 100% sure this should be the longer term fix, but for now it works. |
I've seen this in a project of mine, but in a different scenario (direct on startup)
instead of
because during setup the ViewAssemblies are not loaded yet. |
@JelleDamen That's what we ended up doing in this PR, However I agree with @martijn00 and @nickrandolph This is not a good long term fix as we don't exactly know what gettype().Assembly will give us. It may give us the Mvx or even Mono Droid assembly. |
@vatsalyagoel Ah I see. Any clue why the ViewAssemblies are not loaded, I've not looking into it yet |
@JelleDamen Please have a read through this thread. It explains how viewassemblies are setup and loaded and why in particular scenarios it is not actually loaded properly hence ending up being null |
Let's merge this, and look further into the problem for 6.3. |
when changing permission and going back to the application, ViewAssemblies is null thus causes the app to crash during setup
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Bugfix
When Android forms application is running and you change app permissions when going into Android settings, once you switch back to the app, the app crashes as ViewAssemblies is null. s
🆕 What is the new behavior (if this is a feature change)?
I saw that we have a get view assemblies method which we probably should use instead of referenceing ViewAsemblies directly
💥 Does this PR introduce a breaking change?
No
🐛 Recommendations for testing
Launch App
Go to app Info without closing the app
Enable all permissions available
Go back to app in task switcher
Switch back to permissions
Disable a permission
Switch back to app
App Crashes with error
📝 Links to relevant issues/docs
#2969
Refer https://stackoverflow.com/questions/33488589/android-marshmallow-dynamic-permission-change-kills-all-application-processe
This also fixes the issue when launching the app from MvxIntentService
🤔 Checklist before submitting