Commit Graph

60 Commits (84f4ff0d8652cd1ad0323c86de098f825d9c422e)

Author SHA1 Message Date
Sebastian Kaspari 84f4ff0d86 Issue #17819: Update detekt to 1.17.1 3 years ago
Michael Comella d6999234b0 For #18836: add & integrate StartupTypeTelemetry. 3 years ago
Michael Comella a64540bd06 For #18836: add StartupPathProvider + tests. 3 years ago
Michael Comella ec65737cbb For #18836: address lint errors for StartupStateProvider*. 3 years ago
Michael Comella ea1d569837 For #18836: add getStartupStateForStartedActivity method. 3 years ago
Michael Comella 18507ec24c For #18836: add isHotStartForStartedActivity and tests. 3 years ago
Michael Comella e803cc61a2 For #18836: add isWarmStartForStartedActivity, tests. 3 years ago
Michael Comella ed1f38611f For #18836: shorten isColdStart... and rm questionable test.
The test failed with the rewrite of the code because it violates
one of our assumptions that only one Activity will be started. However,
since it doesn't rely on observed behavior and we made up the events,
it's value is questionable so it seems okay to remove, especially for
the gain of conciseness in the code.
3 years ago
MarcLeclair 990bfa7e6d
16900 make navgraph inflation asynchronous (#18889)
* For #16900: implement async navgraph inflation

For #16900: removed nav graph from xml

For #16900: inflate navGraph programatically

For #16900: Made NavGraph inflation asynchronous

For #16900: Changed to block with runBlocking

For #16900: Refactored blocking call into a function

For 16900: NavGraph inflation is now async

We now attach the nav graph (or check if its attached) on every nav call ( an extension function for NavController).
This is done by checking the value of the job stored in PerfNavController.map which keeps track of the job with the NavController as a Key.
If the job hasn't been completed, it will block the main thread until the job is done. The job itself is responsible for attaching the navgraph
to the navcontroller (and the inflation of the latter too)

For 16900: rebased upstream master

For 16900: Rebase on master

For #16900: Fixed Async Navgraph navigation per review comments.

1)The Asynchronous method is now found in NavGraphProvider.kt. It creates a job on the IO dispatcher
2)The Job is tracked through a WeakHashMap from Controller --> NavGraph
3)The Coroutine scope doesn't use MainScope() anymore
4)The Coroutine is cancelled if the Activity is destroyed
5)The tests mockk the blockForNavGraphInflation method through the FenixReoboelectricTestApplication instead of calling the mock every setup()

For #16900: inflateNavGraphAsync now takes navController

For #16900: Pass lifecycleScope to NavGraphProvider

For #16900: removed unused mock

For #16900: Added linter rules for navigate calls

We need linting rules to make sure no one calls the NavController.navigate() methods

For #16900: Added TestRule to help abstract the mocks in the code

For 16900: Fix linting problems

For #16900: Cleaned duplicated code in tests

For #16900: cleaned up NavGraphTestRule for finished test

For #16900: had to revert an accidentally edited file

For #16900: rebased master

* For #16900: Review nits for async navgraph

This is composed of squash commits, the original messages can be found below:

-> DisableNavGraphProviderAssertionRule + kdoc.

Use test rule in RobolectricApplication.

Fix failing CrashReporterControllerTest

Fix blame by -> navigate in tests.

This commit was generated by the following commands only:
```
find app/src/test -type f -exec sed -i '' "/import org.mozilla.fenix.ext.navigateBlockingForAsyncNavGraph/d" {} \;
find app/src/test -type f -exec sed -i "" "s/navigateBlockingForAsyncNavGraph/navigate/g" {} \;
git checkout app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
```

Fix various blame

This is expected to be squashed into the first commit so, if so, it'd
fix the blame.

Move test rule to helpers pkg.

add missing license header

Add import change I missed

fix unused imports

Replace robolectricTestrunner with test rule.

Improve navGraphProvider docs

Remove unnecessary rule as defined by robolectric.

add clarifying comment to robolectric

remove unnecessary space

* For #16900: nit fixes for MozillaNavigateCheck and lint fixes

3 squash commits:
 *Changed violation message and fixed the lint rule for MozillaNavigateCheck
 *Added suppression to NavController.kt
 *Fixed detekt violations

* For 16900: Fixed failing tests

Co-authored-by: Michael Comella <michael.l.comella@gmail.com>
3 years ago
Michael Comella 5560d7de01 For #18836: rename CreatedActivityLogEntry -> LogEntry.ActivityCreated and similar.
It's too much work to squash "correctly".
3 years ago
Michael Comella 000bef020a For #18836: replace StartupActivityStateProvider with StartupStateProvider.
The StartupActivityStateProvider uses an imperative implementation,
driven by callbacks, to set the state of the application. This is hard
to follow as you need to understand which callbacks will be called in
which order. For example, to make sense of an implementation like this,
COLD, WARM, AND HOT would likely need to be implemented in separate
ActivityLifecycleCallbacks.

I feel the StartupStateProvider is an improvement because it leverages
the StartupActivityLog to query a linear state for a more understandable
implementation. Furthermore, it seems accessible to write COLD, WARM,
and HOT in the same class because they can all be approached the same
way.
3 years ago
Michael Comella 0cbedaadb1 For #18836: add StartupStateProvider. 3 years ago
Michael Comella e864e74960 For #18836: prevent StartupActivityLog from growing infinitely.
We do this is as a separate commit over the original implementation
because it's simpler to implement the class without this optimization.
3 years ago
Michael Comella cde954f3a7 For #18836: add StartupActivityLog, tests. 3 years ago
Michael Comella 6e5b4b3ce6 For #18731: remove anonymous classes from StrictModeManager.
After this change, I took 3 profiles: the new code appeared in the profiler
only once and only for one sample (i.e. possibly just got unlucky). It
seems to be improved. Profiles:
- https://share.firefox.dev/3wifiV2 (captured it)
- https://share.firefox.dev/39xgdHz
- https://share.firefox.dev/2QMdlA0
3 years ago
Michael Comella ade38246be For #18426: record cold start duration telemetry. 3 years ago
Michael Comella 2be9fb61d0 For #18426: add StartupActivityStateProvider.
This will be used to filter conditions for the start up telemetry we're
adding.
3 years ago
Michael Comella edd49b286d For #18426: add ApplicationStartReasonProvider.
We need to know this state to add a correct COLD MAIN probe.
3 years ago
Michael Comella f44611f632 For #18157: convert clock_ticks_per_second to quantity type.
While we could easily move this into the metrics ping, it's better to
leave it in the other ping because it's less work and because (I think)
we'll be better able to match `framework_secondary` values to the clock
ticks if we combine them in the same ping.
3 years ago
Michael Comella 359f27abc1 For #17972: split frameworkStart into two metrics.
We do this in order to make it easier to analyze in GLAM: see the metric
descriptions for more details.

Additionally, we change the time unit to milliseconds to make it easier
to analyze in GLAM.
3 years ago
Michael Comella b41041c739 For #17920: move manufacturer StrictMode exception to ignores function.
I think this is more consistent and centralizes the violation ignores.
3 years ago
Michael Comella 5cb296b098 For #17920: use StrictMode penaltyDeathWithIgnores. 3 years ago
Michael Comella a86b4ef1bd For 17920: add ThreadPenaltyDeathWithIgnoresListener, tests, helpers. 3 years ago
Michael Comella e9e067615a For #17920: add ManufacturerCodes. 3 years ago
Michael Comella 2e45483eb0 For #17816: add ProfilerFactProcessor and register it, tests. 3 years ago
Michael Comella b3ef8a11e8 For #17816: add profiler marker for onPreDraw via HomeActivity.onStart.
This may be useful for MAIN start up to determine when the user begins
seeing content.
3 years ago
MarcLeclair 24bce64e0b
16373 Count the # of inflations done on startup (#16778)
* For #16373: Added performance Inflater to counter # of inflations

This class is quite straight forward. The only thing that I have to point out is the onCreateView method. It usually
calls its super if you don't override it. The problem with that is that the super.onCreateView actually uses
android.view. as a prefix for the XML element it tries to inflate. So if we have an element that isn't part
of that package, it'll crash. As I said in the code, a good example is ImageButton. Calling android.view.ImageButton
will make the app crash. The method is implemented the same way that PhoneLayoutInflater does (Another example
is the AsyncLayoutInflater)

* For #16373: Added test for PerformanceInflater

This test got quite awkward / complicated fast.  I wanted to test the  to make sure we don't break *any* of our layouts
and to do so, I decided to just retrieve all our XML in our /res/layout folder. However, this gets quite a bit outside of a unit test scope.
The point was to get every layouts and get their LayoutID through the resources using the testContext we have. It gets even weirder, since some
of the XML tags have special implementation in android. One of them is the <fragment> tag. That tag actually is inflated by the OS using the Factory2
that the Activity.java implements. In order to get around the fragment issue, we just return a basic FrameLayout since the system LayoutInflater doesn't deal
won't ever get a <fragment> tag to inflate. Another issue was the <merge> tag. In order to inflate those, you need 1) a root view and 2) attach your view to it.
In order to be able to test those layouts file, I had to create an empty FrameLayout and use it as the root view for testing. Again, I know this is beyond the spirit of a unit test but if we use this inflater, I think it should make sure that no layouts are broken by it.

* For #16373: Overrode getSystemService to return PerformanceInflater

This allows PerformanceInflater to be called in every inflation to keep track of the number of inflations we do.

* For #16373: Added UI test for # of inflations

* For #16373: Lint fix

* For #167373: Changed the LayoutInflater cloneInContext to take this instead of inflater

The inflater parameter is set on the first call from the OS from  the Window object. However, the activity itself sets multiple factories on the inflater
during its creation (usually through AppCompatDelegateImpl.java). This means that, once we initially set the inflater with a null check, we pass an inflater
that has no factory initially. However, since we keep a reference to it, when cloneInContext was called, it cloned the inflater with the original inflater
which didn't have any factories set up. This meant that the app would crash on either browserFragment creation or any thing that required appCompat (such as
ImageView and ImageButton). Now, passing itself with a cloneInContext means we keep all the factories initially set by the activity or the fragment.

* For #16373: Fixed code issues for PR. No behavior change

* For #16373: fixed some code nits
3 years ago
Michael Comella e8bf955893 No issue: move StrictModeManager to perf package.
While StrictMode is not exclusively used for performance purposes, it's
primarily used for perf purposes so let's move it to the perf package
and code owner it.
4 years ago
Michael Comella afa080c956 For #15279 - review: set LazyMonitored to private. 4 years ago
Michael Comella 89541a17f7 For #15279: LazyMonitored implement Lazy + update built-in API use.
By having LazyMonitored implement Lazy, we can continue to pass these
values directly into the ac APIs that require Lazy references. For some
reason, implementing `Lazy.value` can replace `operator fun getValue`
required for delegates.
4 years ago
Michael Comella f37ace0630 For #15279: add LazyMonitored and tests. 4 years ago
MarcLeclair 7b1af41b40
15278 detekt rule runblocking (#15942)
* For #15278: added CoroutineManager to count runBlocking calls

* For #15278: Added actual detekt rule for runblocking and its config to the yaml

* For #15278: Added unit test for RunblockingCounter

* For #15278: renamed StrictModeStartupSuppressionCountTest.kt to PerformanceStartupTest.kt and added runBlockingCount test

* Lint fix

* For #15278: made runblocking a Long to prevent overflow

* For #15278: fixed MozRunblocking name, description and moved RunBlockingCounter to perf package

* For #15278:Renamed MozillaRunblockingCheck to MozillaRunBlockingCheck

* For #15278: Added setup for unit test, since it failed without restting counter

* For #15278: Fixed naming for RunBlocking lint check

* For #15278: removed changes made to test to use runBlockingIncrement

* For #15728: added test exclusion for runBlocking check

* For #15278: changed null check and added Synchronized to count setter

* For #15278: fix for nits

* For #15278: added StartupExcessiveResourceUseTest to CODEOWNERS

* For #15278: fixed for nits

* For #15278: Moved increment function to extension function and fixed indentation

* For #15278: Added tests for Atomic Integer extension and nit fix
4 years ago
sraturi 8f16f9cb37 for #10069 added AppLaunchTimeMeasurement.kt to handle logic of startup time for cold, warm, and hot startup types. 4 years ago
sraturi 5ccbca25c0 for #13479, added a VisualCompletenessQueue.kt class to handle all the functionality related to visual completeness 4 years ago
Michael Comella 5d8c900391 For #12802: add StorageStats glean metrics. 4 years ago
Michael Comella 923d841403 For #12345: replace Activity.reportFullyDrawnSafe with a-c impl. 4 years ago
Tiger Oakes c08d375c18
Move settings in components (#12675) 4 years ago
ekager e358f95eed For #12364 - Only show PWA prompt the third time a user visits installable site 4 years ago
Tiger Oakes 6be39aebde
Add tests for StartupReportFullyDrawn (#12560) 4 years ago
Michael Comella 3e617245b5 For #12345: catch SecurityException when calling reportFullyDrawn.
That's amazing! I've got the same combination on my luggage.
4 years ago
Tiger Oakes 9a8b800a76 For #8621 - fix intermittent test failures 4 years ago
mcarare 2090b11c97 For #10434: Handle cases when proc/$pid/stat is not accessible. 4 years ago
mcarare 9ec6ebc92a For #10969: Fix and clarify logic for checking showing PWA dialog. 4 years ago
Simon Chae 5ba9cc6ec9
For #10253: Add disableFirstTimePWAPopup for performance testing (#10442) 4 years ago
Michael Comella f3ed207bdb For #8803 - review: Add clarifying comments to onAppInit capture methods. 4 years ago
Michael Comella f49fc6dad2 For #8803: hook up frameworkStart metric. 4 years ago
Michael Comella dbf733d70a For #8803: add StartupFrameworkStartMeasurement.
This class controls the central logic around the metrics we want to
record.
4 years ago
Michael Comella 7f618a6a7c For #8803: add Stat and test.
We need to access the data in stat to get the process start time, so we
can calculate the time from process start until application.init for the
frameworkStart probe.
4 years ago
Grisha Kruglov be1fa8df7d Pre: introduce a RunWhenReadyQueue
This replaces the StartupTaskManager we had with a more general class.
New implementation is a thread-safe "gated task executor", which either
runs the task right away if it's marked as 'ready', or queries it to be
executed later on.

This ability to either execute or queue a task will be useful later on in the
commit series.
4 years ago
Michael Comella 5bd0369aed No issue: remove unused HotStartPerformanceMonitor.
This monitor for hot start was intended to be used by FNPRMS to measure
hot start. However, hot start was deprioritized so it's now essentially
unused.
4 years ago