Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

For #5799: document architecture choices #5800

Merged
merged 13 commits into from
Oct 21, 2019

Conversation

severinrudie
Copy link
Contributor

@severinrudie severinrudie commented Oct 4, 2019

Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
    Documentation changes only
  • Tests: This PR includes thorough tests or an explanation of why it does not
    Documentation changes only
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
    Documentation changes only
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features
    Documentation changes only

After merge

  • Milestone: Make sure issues finished by this pull request are added to the milestone of the version currently in development.

To download an APK when reviewing a PR:

  1. click on Show All Checks,
  2. click Details next to "Taskcluster (pull_request)" after it appears and then finishes with a green checkmark,
  3. click on the "Fenix - assemble" task, then click "Run Artifacts".
  4. the APK links should be on the left side of the screen, named for each CPU architecture

@severinrudie severinrudie changed the title For #5799: add architecture document outline for review For #5799: document architecture choices Oct 4, 2019
- added complexity
- distinction was removed
- Rx
- slowed startup
Copy link
Contributor

@colintheshots colintheshots Oct 8, 2019

Choose a reason for hiding this comment

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

Coroutines were actually worse until we implemented a fix in R8. Coroutines Dispatchers.Main blocked the main thread >200ms. Rx AndroidSchedulers.MainThread blocked the main thread 42ms on the same hardware. Coroutines are now faster because we strip out the wasted, blocking code using an early version of R8. Long story short, we were using both and had both blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good context, thank you

@st3fan
Copy link
Contributor

st3fan commented Oct 8, 2019

Isn't the HomeActivity the last component that still needs to be moved to the new architecture? It is probably not a good example at this point.

docs/architecture-overview.md Outdated Show resolved Hide resolved
docs/architecture-overview.md Outdated Show resolved Hide resolved
docs/architecture-overview.md Outdated Show resolved Hide resolved
@severinrudie
Copy link
Contributor Author

I also saw that the View's Store is kept in that StoreProvider (an androidx.lifecycle.ViewModel) and also the Fragment state is kept in another ViewModel.
I consider this to be an incorrect usage of the ViewModel given that HomeActivity (and others) do register in manifest for orientation config changes and so the ViewModel's usecase - survice state across screen rotations, is not something that we actually need.

For this doc I'm focused on describing what we have at present for new contributors, rather than suggesting any changes. That is definitely something you could bring up in future architecture work though!

- Remove references to old architecture (Soon it will all have been replaced. No need for the additional cognitive load)
- Add some subheadings
- 'Simplified Example' seems like a good idea. Update the language to clarify that it will be done
@codecov-io
Copy link

codecov-io commented Oct 8, 2019

Codecov Report

Merging #5800 into master will increase coverage by 0.1%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #5800     +/-   ##
===========================================
+ Coverage      14.3%   14.41%   +0.1%     
  Complexity      324      324             
===========================================
  Files           259      256      -3     
  Lines         10700    10522    -178     
  Branches       1560     1532     -28     
===========================================
- Hits           1531     1517     -14     
+ Misses         9044     8879    -165     
- Partials        125      126      +1
Impacted Files Coverage Δ Complexity Δ
...rc/main/java/org/mozilla/fenix/ext/BookmarkNode.kt 0% <0%> (-50%) 0% <0%> (ø)
.../fenix/browser/browsingmode/BrowsingModeManager.kt 22.22% <0%> (-44.45%) 0% <0%> (ø)
...pp/src/main/java/org/mozilla/fenix/FeatureFlags.kt 88.88% <0%> (-11.12%) 2% <0%> (ø)
...g/mozilla/fenix/crashes/CrashReporterController.kt 94.11% <0%> (-1.34%) 6% <0%> (ø)
...in/java/org/mozilla/fenix/settings/SupportUtils.kt 60% <0%> (-1.12%) 8% <0%> (ø)
...illa/fenix/components/toolbar/BrowserInteractor.kt 95.65% <0%> (-0.19%) 11% <0%> (ø)
...org/mozilla/fenix/crashes/CrashReporterFragment.kt 0% <0%> (ø) 0% <0%> (ø) ⬇️
...kmarks/selectfolder/SelectBookmarkFolderAdapter.kt 0% <0%> (ø) 0% <0%> (ø) ⬇️
...a/org/mozilla/fenix/components/IntentProcessors.kt 0% <0%> (ø) 0% <0%> (ø) ⬇️
...x/home/sessioncontrol/viewholders/TabViewHolder.kt 0% <0%> (ø) 0% <0%> (ø) ⬇️
... and 59 more

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 d0a39f0...fdde820. Read the comment docs.

@severinrudie severinrudie force-pushed the 5799-document-architecture branch 4 times, most recently from c9b7fed to 12cd76a Compare October 16, 2019 22:00
- see `differences from previous architecture` for more in depth description of changes made to reduce complexity


## Architecture Overview
Copy link
Contributor Author

@severinrudie severinrudie Oct 16, 2019

Choose a reason for hiding this comment

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

NOTE TO REVIEWERS: the formatted version of this may be easier to review

EDIT: forgot I renamed that file. Link fixed

@@ -0,0 +1,159 @@
## Architecture Overview
Copy link
Contributor Author

@severinrudie severinrudie Oct 16, 2019

Choose a reason for hiding this comment

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

NOTE TO REVIEWERS: the formatted version of this may be easier to review

EDIT: forgot I renamed that file. Link fixed

@severinrudie severinrudie marked this pull request as ready for review October 16, 2019 22:41
Copy link
Contributor

@csadilek csadilek left a comment

Choose a reason for hiding this comment

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

Great work @baron-severin! I've added a few comments but this is already super comprehensive.

docs/architecture-overview.md Outdated Show resolved Hide resolved
docs/architecture-overview.md Outdated Show resolved Hide resolved
docs/architecture-overview.md Outdated Show resolved Hide resolved
Is pushed to: [Store](#store)

#### Description
Simple data object that carries information about a [State](#state) change to a [Store](#store). An Action describes _something that happened_, and carries any data relevant to that change. For example, `AccountSettingsFragmentAction.SyncFailed(val time: Long)`, which describes a sync that failed at a specific time.
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting we're not super consistent with Action naming. They can be reactive, describing something that has happened or active, describing something that should happen e.g. UpdateQuery.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think this is a symptom of some blending of responsibilities between Controllers and Reducers. When the Controller handles the logic, the Action winds up essentially being a setter.

docs/architecture-overview.md Show resolved Hide resolved

See [mozilla.components.lib.state.Action](https://github.com/mozilla-mobile/android-components/blob/master/components/lib/state/src/main/java/mozilla/components/lib/state/Action.kt)

Created by: [Controller](#controller)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to list every possible thing that can create these? There are cases where Actions are created outside of the controller

Copy link
Contributor Author

@severinrudie severinrudie Oct 21, 2019

Choose a reason for hiding this comment

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

Oof, I didn't realize. I know they used to be created in Interactors, but my understanding was that we were moving away from that and towards Controllers. Where else are they created?

EDIT: better question, is it fine that they are sent from a variety of places, or do we want them to only be sent by Controllers in the future? I don't have the context to answer this one.

Copy link
Contributor

@boek boek left a comment

Choose a reason for hiding this comment

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

This is awesome! I'm going to land this, do you want to update this wiki page with a reference to this? https://github.com/mozilla-mobile/fenix/wiki/Architecture-Decisions

@boek boek merged commit a0ca8b8 into mozilla-mobile:master Oct 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants