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

Fix verification failed issue, simplify verification logic #3830

Merged
merged 8 commits into from
Nov 8, 2024

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Nov 7, 2024

Content

  • Avoid unnecessary initVerificationControllerIfNeeded call which caused the automatic verification flow failure.
  • Reuse Rust Client instances created on the login process so we don't need to restore one right before the session verification.
  • Remove unnecessary sources of verification state updates.
  • Add an intermediate FTUE flow step which will display an indeterminate progress indicator instead of a blank screen.

Motivation and context

This should fix the issues we've seen where the authentication failed automatically due to a race condition.

Keeping the Client instances created on login would also make our setup more similar to iOS and avoid unnecessary work.

Tests

  • Login and verify your device (self-verification).
  • Try verifying some other device from this one.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

- Reuse Rust `Client` instances created on the login process so we don't need to restore one right before the session verification.
- Remove unnecessary sources of verification state updates.
- Add an intermediate FTUE flow step which will display an indeterminate progress indicator instead of a blank screen.
@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Nov 7, 2024
@jmartinesp jmartinesp requested a review from a team as a code owner November 7, 2024 14:45
@jmartinesp jmartinesp requested review from bmarty and removed request for a team November 7, 2024 14:45
@jmartinesp jmartinesp added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Nov 7, 2024
// Otherwise, just check the current verification status from the session verification controller instead
Timber.d("Updating verification status: flow is pending or was finished some time ago")
runCatching {
initVerificationControllerIfNeeded()
Copy link
Member Author

Choose a reason for hiding this comment

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

This line here is what caused the automatic verification failure if it was called before the verification service was ready.

Copy link
Contributor

github-actions bot commented Nov 7, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/PjSgyH

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.

A first few remarks.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 82.98%. Comparing base (cf9dbc6) to head (0b00150).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...atrix/test/auth/FakeMatrixAuthenticationService.kt 63.63% 0 Missing and 4 partials ⚠️
...oid/features/ftue/impl/state/DefaultFtueService.kt 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3830      +/-   ##
===========================================
- Coverage    82.98%   82.98%   -0.01%     
===========================================
  Files         1783     1783              
  Lines        44971    44980       +9     
  Branches      5289     5293       +4     
===========================================
+ Hits         37320    37327       +7     
+ Misses        5805     5803       -2     
- Partials      1846     1850       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Some remarks, still testing on my side

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.

I'll merge develop on it and do more test, but it looks OK!

@@ -81,4 +81,17 @@ class MatrixClientsHolderTest {
matrixClientsHolder.restoreWithSavedState(savedStateMap)
assertThat(matrixClientsHolder.getOrNull(A_SESSION_ID)).isEqualTo(fakeMatrixClient)
}

@Test
fun `test ClientAuthenticationObserver emits a value and we save it`() = runTest {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename this test now that ClientAuthenticationObserver has been deleted.

}
.first()
return readyVerifiedSessionStatus == SessionVerifiedStatus.NotVerified && !canSkipVerification()
// Wait until the session verification status is known
Copy link
Member

Choose a reason for hiding this comment

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

Neat: the @OptIn can be removed.

* In this case, the FTUE flow is ready when the session verification status is known.
*/
@OptIn(FlowPreview::class)
val isVerificationStatusKnown = sessionVerificationService.sessionVerifiedStatus
Copy link
Member

Choose a reason for hiding this comment

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

Neat: the @OptIn can be removed (twice in this file).

analyticsService = analyticsService,
permissionStateProvider = permissionStateProvider,
lockScreenService = lockScreenService,
)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for this new test!

Copy link

sonarcloud bot commented Nov 8, 2024

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.

Thanks for the update.
I have done more tests and this seems to be fine.
We will need to handle the problem when Element Web is accepting an incoming verification request even if it does not know the private key. In this case, the Element X session will not become verified.

This is tracked by element-hq/element-web#27655

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Nov 8, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Nov 8, 2024
@jmartinesp jmartinesp merged commit 2206e94 into develop Nov 8, 2024
29 of 30 checks passed
@jmartinesp jmartinesp deleted the fix/jme/simplify-verification-service branch November 8, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bugfix For bug fix Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants