text
stringlengths 1
474
|
|---|
Therefore, a compilation could cause tens of frames
|
to be missed, and drop the fps from 60 to 6.
|
This is compilation jank.
|
After the compilation is complete,
|
the animation should be smooth.On the other hand, Impeller generates and compiles all
|
necessary shaders when we build the Flutter Engine.
|
Therefore apps running on Impeller already have
|
all the shaders they need, and the shaders can be used
|
without introducing jank into animations.Definitive evidence for the presence of shader compilation jank
|
is to set GrGLProgramBuilder::finalize in the tracing
|
with --trace-skia enabled.
|
The following screenshot shows an example timeline tracing.<topic_end>
|
<topic_start>
|
What do we mean by “first run”?
|
On iOS, “first run” means that the user might see
|
jank when an animation first occurs every time
|
the user opens the app from scratch.<topic_end>
|
<topic_start>
|
How to use SkSL warmup
|
Flutter provides command line tools
|
for app developers to collect shaders that might be needed
|
for end-users in the SkSL (Skia Shader Language) format.
|
The SkSL shaders can then be packaged into the app,
|
and get warmed up (pre-compiled) when an end-user first
|
opens the app, thereby reducing the compilation
|
jank in later animations.
|
Use the following instructions to collect
|
and package the SkSL shaders:Run the app with --cache-sksl turned on
|
to capture shaders in SkSL:If the same app has been previously run
|
without --cache-sksl, then the
|
--purge-persistent-cache flag might be needed:This flag removes older non-SkSL shader caches that
|
could interfere with SkSL shader capturing.
|
It also purges the SkSL shaders so use it only on the first
|
--cache-sksl run.Play with the app to trigger as many animations
|
as needed; particularly those with compilation jank.Press M at the command line of flutter run to
|
write the captured SkSL shaders into a file named something like
|
flutter_01.sksl.json.
|
For best results,
|
capture SkSL shaders on an actual iOS device.
|
A shader captured on a simulator isn’t likely to work correctly
|
on actual hardware.Build the app with SkSL warm-up using the following,
|
as appropriate:If it’s built for a driver test like test_driver/app.dart,
|
make sure to also specify --target=test_driver/app.dart
|
(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.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.