Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Update to Application Services v73.0.1 #9731

Merged
merged 2 commits into from
Mar 11, 2021

Conversation

rfk
Copy link
Contributor

@rfk rfk commented Feb 19, 2021

Update: The new version of Application Services has been released and it includes auto-generated bindings for the fxaclient component. This PR updates the appservices version and provides the necessary tweaks for API changes.

I've tested this manually in a local build of Fenix and account- and send-tab-related functionality seems to be working well.

--
Over in mozilla/application-services#3876 I'm working on a significant restructure of the fxa-client Rust component, aiming to use our new bindings-generation tool to replace a bunch of hand-written code. This PR captures the corresponding a-c changes to adapt to the minor API differences between authgenerated and hand-written code.

It's not appropriate to merge yet, but I wanted to push it for early visible and feedback, particularly if any of the changes here seem like the sort of thing we should not be doing. /cc @grigoryk @jonalmeida

@@ -173,7 +173,7 @@ val accountEventsObserver = object : AccountEventsObserver {
override fun onEvents(event: List<AccountEvent>) {
// device received some commands; for example, here's how you can process incoming Send Tab commands:
commands
.filter { it is AccountEvent.IncomingDeviceCommand }
.filter { it is AccountEvent.CommandReceived }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to change the name of this variant for dumb code-gen-related reasons, but I also prefer "command received" because it maps more directly to the of the push notification.

@@ -7,28 +7,28 @@ package mozilla.components.service.fxa
/**
* High-level exception class for the exceptions thrown in the Rust library.
*/
typealias FxaException = mozilla.appservices.fxaclient.FxaException
typealias FxaException = mozilla.appservices.fxaclient.FxaErrorException
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Name change due to current limitations of bindings generator, which has strong opinions about the name of exception classes.

@@ -104,25 +107,25 @@ fun Profile.into(): mozilla.components.concept.sync.Profile {
)
}

internal fun Device.Type.into(): DeviceType {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The bindings generated doesn't support these nested namespace things yet, so e.g. Device.Type is now DeviceType.

from = this.from?.into(),
entries = this.entries.map { it.into() }
from = this.sender?.into(),
entries = this.payload.entries.map { it.into() }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The field names here were different between the Rust code and the hand-written Kotlin wrapper, and now that things are autogenerated they're the same.

ASAccountEvent.IncomingDeviceCommand(
command = IncomingDeviceCommand.TabReceived(testDevice1, arrayOf(testTab1))
ASAccountEvent.CommandReceived(
command = IncomingDeviceCommand.TabReceived(testDevice1, SendTabPayload(listOf(testTab1), "flowid", "streamid"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The bindings generator uses lists, the a-c code here seems to prefer arrays. I'm not familiar enough with the differences in Kotlin to know under which circumstances the different types should be preferred. Should we invest in making the generated bindings accept an array rather than a list here?

Copy link
Contributor

Choose a reason for hiding this comment

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

A list should be fine.

@codecov
Copy link

codecov bot commented Feb 19, 2021

Codecov Report

Merging #9731 (3167b55) into master (5ad1fc3) will decrease coverage by 0.00%.
The diff coverage is 20.83%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #9731      +/-   ##
============================================
- Coverage     74.04%   74.04%   -0.01%     
  Complexity     5655     5655              
============================================
  Files           773      773              
  Lines         28766    28764       -2     
  Branches       4738     4737       -1     
============================================
- Hits          21301    21299       -2     
  Misses         4986     4986              
  Partials       2479     2479              
Impacted Files Coverage Δ Complexity Δ
.../java/mozilla/components/service/fxa/Exceptions.kt 75.00% <ø> (ø) 0.00 <0.00> (ø)
...a/mozilla/components/service/fxa/FirefoxAccount.kt 17.02% <0.00%> (ø) 4.00 <0.00> (ø)
...a/components/service/fxa/FxaDeviceConstellation.kt 63.15% <ø> (ø) 12.00 <0.00> (ø)
...n/java/mozilla/components/service/nimbus/Nimbus.kt 50.95% <0.00%> (ø) 13.00 <0.00> (ø)
.../main/java/mozilla/components/service/fxa/Types.kt 35.71% <25.00%> (ø) 0.00 <0.00> (ø)
...ava/mozilla/components/support/migration/Result.kt 100.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
...onents/support/sync/telemetry/BaseGleanSyncPing.kt 100.00% <0.00%> (ø) 11.00% <0.00%> (ø%)
...onents/lib/crash/notification/CrashNotification.kt 91.42% <0.00%> (+0.25%) 2.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ad1fc3...3167b55. Read the comment docs.

@@ -130,7 +130,7 @@
style="?android:attr/listSeparatorTextViewStyle"
android:text="@string/devices" />

<FragmentContainerView android:name="org.mozilla.samples.sync.DeviceFragment"
<androidx.fragment.app.FragmentContainerView android:name="org.mozilla.samples.sync.DeviceFragment"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting weird unrelated crashes when trying to build and run the sample app, and Google told me to change this, and it worked. Does this seem familiar to anyone else, and maybe indicate a problem with my local build env?

(I don't think it's related to the changes from this PR, because I was getting the same build issues on a clean checkout of a-c).

@rfk rfk changed the title WIP updates for compatibility with UniFFI-ied fxa-client component. Update to Application Services v73.0.1 Mar 10, 2021
@@ -30,7 +30,7 @@ object Versions {
const val disklrucache = "2.0.2"
const val leakcanary = "2.4"

const val mozilla_appservices = "72.1.0"
const val mozilla_appservices = "73.0.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One unrelated warning about this release: we have some weird build issues going on with Windows Desktop builds at the moment, ref mozilla/application-services#3917. The -forUnitTests variant of appservices 73.0.1 does not include a Windows dll, which IIUC means that a-c developers would not be able to run unittests that use appservices code on a Windows host.

It's not clear to me how much of a dealbreaker that is for y'all. I opted to disable Windows builds for this release in order to get something out the door that we can play with, and on the appservices side we're happy to ship a release without them. But, if it's important for a-c or Fenix developers to have this capability, we'll try to followup with a 73.0.2 release that restores them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for flagging this, Ryan! Perhaps we can mention this in the changelog as part of this PR, as a temporary (I'm assuming) condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added an entry to the changelog, with a link to the underlying appservices issue for followup 👍

@rfk rfk requested a review from grigoryk March 10, 2021 09:51
@rfk rfk marked this pull request as ready for review March 10, 2021 09:54
@rfk rfk requested review from a team as code owners March 10, 2021 09:54
@@ -29,7 +29,7 @@ import org.mozilla.experiments.nimbus.AvailableRandomizationUnits
import org.mozilla.experiments.nimbus.EnrolledExperiment
import org.mozilla.experiments.nimbus.EnrollmentChangeEvent
import org.mozilla.experiments.nimbus.EnrollmentChangeEventType
import org.mozilla.experiments.nimbus.ErrorException
import org.mozilla.experiments.nimbus.NimbusErrorException
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, you're also getting a new Nimbus release, which had to rename this error class because the name Error was causing problems with the Swift bindings.

Copy link
Member

@travis79 travis79 left a comment

Choose a reason for hiding this comment

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

Aside from the detekt lint about UndocumentedPublicFunction in the Types.kt file, this looks good to me.

@rfk
Copy link
Contributor Author

rfk commented Mar 10, 2021

Aside from the detekt lint about UndocumentedPublicFunction in the Types.kt file

They were like that when I got here, I swear! 😅

Seriously though, I don't really understand why my changes triggered this lint, but I'll add some docs for completeness.

Copy link
Contributor

@grigoryk grigoryk left a comment

Choose a reason for hiding this comment

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

Thank you!

@@ -30,7 +30,7 @@ object Versions {
const val disklrucache = "2.0.2"
const val leakcanary = "2.4"

const val mozilla_appservices = "72.1.0"
const val mozilla_appservices = "73.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for flagging this, Ryan! Perhaps we can mention this in the changelog as part of this PR, as a temporary (I'm assuming) condition?

@@ -144,7 +144,7 @@ class FirefoxAccount internal constructor(
accessType: AccessType
) = withContext(scope.coroutineContext) {
handleFxaExceptions(logger, "authorizeOAuthCode", { null }) {
val params = AuthorizationParams(clientId, scopes, state, accessType.msg)
val params = AuthorizationParameters(clientId, scopes.toList(), state, accessType.msg, null, null, null)
Copy link
Contributor

Choose a reason for hiding this comment

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

slightly offtopic for this PR, and we already discussed this in slack: it took me a bit of clicking around to figure out that the missing params here are for the PKCE code exchange. I think it's only documented at https://github.com/mozilla/application-services/blob/d77600e32c19cbeebaf1045a1b9b49476530e770/components/fxa-client/src/internal/oauth.rs#L194

Also, filed #9863 to remove this from the API surface for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we could use named argument syntax here to make things bit clearer, e.g. AuthorizationParameters(..., pkceParams=null, keysJwk=null).

I also expect a future release to support default values for these arguments which might help clean it up a bit more.

@mergify
Copy link
Contributor

mergify bot commented Mar 10, 2021

This pull request has conflicts when rebasing. Could you fix it @rfk? 🙏

This release includes new auto-generated Kotlin bindings for the FxA Client
component, which come with a few breaking API changes. There should be
no changes in functionality though.
@mergify mergify bot merged commit 2522696 into mozilla-mobile:master Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🛬 needs landing PRs that are ready to land
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants