5#include "flutter/common/graphics/persistent_cache.h"
9#include "flutter/assets/directory_asset_bundle.h"
10#include "flutter/flow/layers/container_layer.h"
11#include "flutter/flow/layers/layer.h"
12#include "flutter/fml/command_line.h"
13#include "flutter/fml/file.h"
14#include "flutter/fml/log_settings.h"
15#include "flutter/fml/unique_fd.h"
16#include "flutter/shell/common/shell_test.h"
17#include "flutter/shell/common/switches.h"
18#include "flutter/shell/version/version.h"
19#include "flutter/testing/testing.h"
27 const std::string& expected) {
28 std::string data_string(
reinterpret_cast<const char*
>(
data->bytes()),
30 ASSERT_EQ(data_string, expected);
40 ASSERT_EQ(shaders.size(), 2u);
53 const std::string kTestJson =
56 " \"IE\": \"eA==\",\n"
64 auto data = std::make_unique<fml::DataMapping>(
65 std::vector<uint8_t>{kTestJson.begin(), kTestJson.end()});
70 auto settings = CreateSettingsForFixture();
78 auto asset_manager = std::make_shared<AssetManager>();
80 asset_manager->PushBack(std::make_unique<DirectoryAssetBundle>(
89 ASSERT_EQ(shaders.size(), 2u);
93 if (shaders[0].
key->bytes()[0] ==
'B') {
112 {
"flutter_engine", GetFlutterEngineVersion(),
"skia"},
115 constexpr char kOldEngineVersion[] =
"old";
117 base_dir.
fd(), {
"flutter_engine", kOldEngineVersion,
"skia"},
119 ASSERT_TRUE(old_created.is_valid());
129 ASSERT_TRUE(engine_dir.is_valid());
130 ASSERT_TRUE(current_dir.is_valid());
131 ASSERT_FALSE(old_dir.is_valid());
142 {
"flutter_engine", GetFlutterEngineVersion(),
"skia", GetSkiaVersion()},
151 ASSERT_TRUE(
file.is_valid());
154 auto settings = CreateSettingsForFixture();
155 settings.purge_persistent_cache =
true;
158 RunEngine(
shell.get(), std::move(config));
162 ASSERT_FALSE(
file.is_valid());
166 DestroyShell(std::move(
shell));
180 auto settings = CreateSettingsForFixture();
181 settings.purge_persistent_cache =
true;
185 RunEngine(
shell.get(), std::move(config));
187 ASSERT_EQ(persistent_cache->LoadSkSLs().size(), 0u);
190 StorePersistentCache(persistent_cache, *shader_key, *shader_value);
191 std::promise<bool> io_flushed;
192 shell->GetTaskRunners().GetIOTaskRunner()->PostTask(
193 [&io_flushed]() { io_flushed.set_value(
true); });
194 io_flushed.get_future().get();
195 ASSERT_GT(persistent_cache->LoadSkSLs().size(), 0u);
199 DestroyShell(std::move(
shell));
void swap(sk_sp< T > &a, sk_sp< T > &b)
static sk_sp< SkData > MakeWithCString(const char cstr[])
static void SetAssetManager(std::shared_ptr< AssetManager > value)
static void SetCacheDirectoryPath(std::string path)
static PersistentCache * GetCacheForProcess()
static constexpr char kAssetFileName[]
static void ResetCacheForProcess()
std::vector< SkSLCache > LoadSkSLs() const
Load all the SkSL shader caches in the right directory.
static std::string SkKeyToFilePath(const SkData &key)
Specifies all the configuration required by the runtime library to launch the root isolate....
static RunConfiguration InferFromSettings(const Settings &settings, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup)
Attempts to infer a run configuration from the settings object. This tries to create a run configurat...
const std::string & path() const
TEST_F(DisplayListTest, Defaults)
static void CheckTextSkData(const sk_sp< SkData > &data, const std::string &expected)
static void CheckTwoSkSLsAreLoaded()
static void ResetAssetManager()
const char * GetFlutterEngineVersion()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent Remove all existing persistent cache This is mainly for debugging purposes such as reproducing the shader compilation jank trace to file
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
fml::UniqueFD OpenFileReadOnly(const fml::UniqueFD &base_directory, const char *path)
bool RemoveFilesInDirectory(const fml::UniqueFD &directory)
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
fml::UniqueFD OpenDirectoryReadOnly(const fml::UniqueFD &base_directory, const char *path)
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
static fml::UniqueFD CreateDirectory(const fml::UniqueFD &base_directory, const std::vector< std::string > &components, FilePermission permission, size_t index)
constexpr LogSeverity kLogWarning
bool UnlinkFile(const char *path)