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

FTUE - Crash fixes #6862

Merged
merged 8 commits into from
Aug 22, 2022
Merged

FTUE - Crash fixes #6862

merged 8 commits into from
Aug 22, 2022

Conversation

ouchadam
Copy link
Contributor

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Motivation and context

Screenshots / GIFs

WebView disabled

*animations are disabled

Before After
before-webview-disabled disable-webview

Tests



Tested devices

  • Physical
  • Emulator
  • OS version(s): 28, 31

@ouchadam ouchadam added Z-Crash Z-FTUE Issue is relevant to the first time use project or experience labels Aug 17, 2022
@@ -260,11 +260,11 @@ class FtueAuthVariant(
}

private fun onStartCombinedLogin() {
addRegistrationStageFragmentToBackstack(FtueAuthCombinedLoginFragment::class.java)
addRegistrationStageFragmentToBackstack(FtueAuthCombinedLoginFragment::class.java, allowStateLoss = true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

allowing state loss for the entry fragments is the fix for #6861

try {
inflate()
} catch (e: Exception) {
val isMissingWebView = e.crawlCausesFor { it.message?.contains("MissingWebViewPackageException").orFalse() }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we have to crawl through the exception causes to find the missing webview package exception, it's a bit hacky~

}

private fun inflateWebViewOrShowError() {
views.loginCaptchaWebViewStub.inflateWebView(onError = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

using the ViewStub and handling the inflation error is the fix for #6855

@@ -492,17 +489,6 @@ class OnboardingViewModel @AssistedInject constructor(

private fun handleInitWith(action: OnboardingAction.InitWith) {
loginConfig = action.loginConfig
// If there is a pending email validation continue on this step
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the attempt to fast forward the onboarding state to the wait for email verification stage when the app has been killed and relaunched is the fix for #6860

The OnboardingViewModel and OnboardingViewState already support and are restored by the system restoration process. If the process has been destroyed we need to accumulate the previous view states again otherwise we end up with invalid state.

@ouchadam ouchadam requested review from a team and Florian14 and removed request for a team August 17, 2022 14:11
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Could be rewritten to this compact, but maybe less clear:

private fun Throwable.crawlCausesFor(predicate: (Throwable) -> Boolean): Boolean {
    return predicate(this) || cause?.crawlCausesFor(predicate) ?: false
}

Also, maybe move this extension to a dedicated file for Throwable extensions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will extract 👍

as the function is recursive I'd lean towards making the exit conditions as clear as possible, having the recursive call the last line allows us to opt into the tailrec optimisations (although it hasn't been used here since the crash stack is fairly small)

… app is destroyed

- this behaviour puts the app in an invalid state as we've lost all the ViewState we've collect from the previous onboarding steps
- the app already handles restoring the onboarding state via the system restoration
… the system webview is missing or has been disabled
@ouchadam ouchadam force-pushed the feature/adm/ftue-fragment-crashes branch from 0b2b28d to 8b70f3a Compare August 18, 2022 10:41
@ElementBot
Copy link

Warnings
⚠️

vector/src/main/res/layout/fragment_ftue_login_captcha.xml#L8 - Possible overdraw: Root element paints background ?android:colorBackground with a theme that also paints a background (inferred theme is @style/Theme.Vector.Light)

⚠️

vector/src/main/res/layout/fragment_ftue_login_captcha.xml#L8 - Possible overdraw: Root element paints background ?android:colorBackground with a theme that also paints a background (inferred theme is @style/Theme.Vector.Light)

Generated by 🚫 dangerJS against 106fa1b

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

31.2% 31.2% Coverage
0.0% 0.0% Duplication

@ouchadam ouchadam added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Aug 22, 2022
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM

@ouchadam ouchadam merged commit 0be46ad into develop Aug 22, 2022
@ouchadam ouchadam deleted the feature/adm/ftue-fragment-crashes branch August 22, 2022 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Crash Z-FTUE Issue is relevant to the first time use project or experience Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
3 participants