text stringlengths 1 372 |
|---|
(for example, flutter build ios --bundle-sksl-path |
flutter_01.sksl.json --target=test_driver/app.dart). |
test the newly built app. |
alternatively, you can write some integration tests to |
automate the first three steps using a single command. |
for example: |
with such integration tests, |
you can easily and reliably get the |
new SkSLs when the app code changes, |
or when flutter upgrades. |
such tests can also be used to verify the performance change |
before and after the SkSL warm-up. |
even better, you can put those tests into a |
CI (continuous integration) system so the |
SkSLs are generated and tested automatically over the lifetime of an app. |
info note |
the integration_test package is now the recommended way |
to write integration tests. refer to the |
integration testing |
page for details. |
take the original version of flutter gallery as an example. |
the CI system is set up to generate SkSLs for every flutter commit, |
and verifies the performance, in the transitions_perf_test.dart test. |
for more details, |
check out the flutter_gallery_sksl_warmup__transition_perf and |
flutter_gallery_sksl_warmup__transition_perf_e2e_ios32 tasks. |
the worst frame rasterization time is a useful metric from |
such integration tests to indicate the severity of shader |
compilation jank. |
for instance, |
the steps above reduce flutter gallery’s shader compilation |
jank and speeds up its worst frame rasterization time on a |
moto g4 from ~90 ms to ~40 ms. on iPhone 4s, |
it’s reduced from ~300 ms to ~80 ms. that leads to the visual |
difference as illustrated in the beginning of this article. |
<topic_end> |
<topic_start> |
performance metrics |
for a complete list of performance metrics flutter measures per commit, visit |
the following sites, click query, and filter the test and |
sub_result fields: |
<topic_end> |
<topic_start> |
concurrency and isolates |
all dart code runs in isolates, |
which are similar to threads, |
but differ in that isolates have their own isolated memory. |
they do not share state in any way, |
and can only communicate by messaging. |
by default, |
flutter apps do all of their work on a single isolate – |
the main isolate. |
in most cases, this model allows for simpler programming and |
is fast enough that the application’s UI doesn’t become unresponsive. |
sometimes though, |
applications need to perform exceptionally large computations |
that can cause “ui jank” (jerky motion). |
if your app is experiencing jank for this reason, |
you can move these computations to a helper isolate. |
this allows the underlying runtime environment |
to run the computation concurrently |
with the main UI isolate’s work |
and takes advantage of multi-core devices. |
each isolate has its own memory |
and its own event loop. |
the event loop processes |
events in the order that they’re added to an event queue. |
on the main isolate, |
these events can be anything from handling a user tapping in the UI, |
to executing a function, |
to painting a frame on the screen. |
the following figure shows an example event queue |
with 3 events waiting to be processed. |
for smooth rendering, |
flutter adds a “paint frame” event to the event queue |
60 times per second(for a 60hz device). |
if these events aren’t processed on time, |
the application experiences UI jank, |
or worse, |
become unresponsive altogether. |
whenever a process can’t be completed in a frame gap, |
the time between two frames, |
it’s a good idea to offload the work to another isolate |
to ensure that the main isolate can produce 60 frames per second. |
when you spawn an isolate in dart, |
it can process the work concurrently with the main isolate, |
without blocking it. |
you can read more about how isolates |
and the event loop work in dart on |
the concurrency page of the dart |
documentation. |
<topic_end> |
<topic_start> |
common use cases for isolates |
there is only one hard rule for when you should use isolates, |
and that’s when large computations are causing your flutter application |
to experience UI jank. |
this jank happens when there is any computation that takes longer than |
flutter’s frame gap. |
any process could take longer to complete, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.