Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b176042c
Unverified
Commit
b176042c
authored
Apr 29, 2020
by
Emmanuel Garcia
Committed by
GitHub
Apr 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add benchmark for hybrid composition on Android (#55609)
parent
deb0fa37
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
206 additions
and
19 deletions
+206
-19
android_platform_view.dart
...arks/platform_views_layout/lib/android_platform_view.dart
+87
-0
main.dart
dev/benchmarks/platform_views_layout/lib/main.dart
+23
-6
pubspec.yaml
dev/benchmarks/platform_views_layout/pubspec.yaml
+1
-2
android_texture_scroll_perf.dart
...views_layout/test_driver/android_texture_scroll_perf.dart
+17
-0
android_view_scroll_perf.dart
...rm_views_layout/test_driver/android_view_scroll_perf.dart
+17
-0
uikit_view_scroll_perf.dart
...form_views_layout/test_driver/uikit_view_scroll_perf.dart
+3
-1
android_view_scroll_perf__timeline_summary.dart
...bin/tasks/android_view_scroll_perf__timeline_summary.dart
+14
-0
platform_views_scroll_perf__timeline_summary.dart
...n/tasks/platform_views_scroll_perf__timeline_summary.dart
+1
-1
platform_views_scroll_perf_ios__timeline_summary.dart
...sks/platform_views_scroll_perf_ios__timeline_summary.dart
+1
-1
perf_tests.dart
dev/devicelab/lib/tasks/perf_tests.dart
+36
-8
manifest.yaml
dev/devicelab/manifest.yaml
+6
-0
No files found.
dev/benchmarks/platform_views_layout/lib/android_platform_view.dart
0 → 100644
View file @
b176042c
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
class
AndroidPlatformView
extends
StatelessWidget
{
/// Creates a platform view for Android, which is rendered as a
/// native view.
/// `viewType` identifies the type of Android view to create.
const
AndroidPlatformView
({
Key
key
,
@required
this
.
viewType
,
})
:
assert
(
viewType
!=
null
),
super
(
key:
key
);
/// The unique identifier for the view type to be embedded by this widget.
///
/// A PlatformViewFactory for this type must have been registered.
final
String
viewType
;
@override
Widget
build
(
BuildContext
context
)
{
return
PlatformViewLink
(
viewType:
viewType
,
onCreatePlatformView:
_onCreateAndroidView
,
surfaceFactory:
(
BuildContext
context
,
PlatformViewController
controller
)
{
return
PlatformViewSurface
(
controller:
controller
,
gestureRecognizers:
const
<
Factory
<
OneSequenceGestureRecognizer
>>{},
hitTestBehavior:
PlatformViewHitTestBehavior
.
opaque
,
);
},
);
}
PlatformViewController
_onCreateAndroidView
(
PlatformViewCreationParams
params
)
{
final
_AndroidViewController
controller
=
_AndroidViewController
(
params
.
id
,
viewType
);
controller
.
_initialize
().
then
((
_
)
{
params
.
onPlatformViewCreated
(
params
.
id
);
});
return
controller
;
}
}
// TODO(egarciad): The Android view controller should be defined in the framework.
// https://github.com/flutter/flutter/issues/55904
class
_AndroidViewController
extends
PlatformViewController
{
_AndroidViewController
(
this
.
viewId
,
this
.
viewType
,
);
@override
final
int
viewId
;
/// The unique identifier for the Android view type to be embedded by this widget.
///
/// A PlatformViewFactory for this type must have been registered.
final
String
viewType
;
bool
_initialized
=
false
;
Future
<
void
>
_initialize
()
async
{
// TODO(egarciad): Initialize platform view.
_initialized
=
true
;
}
@override
void
clearFocus
()
{
// TODO(egarciad): Implement clear focus.
}
@override
void
dispatchPointerEvent
(
PointerEvent
event
)
{
// TODO(egarciad): Implement dispatchPointerEvent
}
@override
void
dispose
()
{
if
(
_initialized
)
{
// TODO(egarciad): Dispose the android view.
}
}
}
dev/benchmarks/platform_views_layout/lib/main.dart
View file @
b176042c
...
...
@@ -7,13 +7,23 @@ import 'dart:io';
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
show
timeDilation
;
import
'android_platform_view.dart'
;
void
main
(
)
{
runApp
(
PlatformViewApp
()
const
PlatformViewApp
()
);
}
class
PlatformViewApp
extends
StatefulWidget
{
const
PlatformViewApp
({
Key
key
,
this
.
enableHybridCompositionOnAndroid
=
false
,
})
:
super
(
key:
key
);
/// Whether to use render the Android view as a platform view or a texture.
final
bool
enableHybridCompositionOnAndroid
;
@override
PlatformViewAppState
createState
()
=>
PlatformViewAppState
();
...
...
@@ -37,7 +47,6 @@ class PlatformViewAppState extends State<PlatformViewApp> {
}
}
class
PlatformViewLayout
extends
StatelessWidget
{
const
PlatformViewLayout
({
Key
key
})
:
super
(
key:
key
);
...
...
@@ -74,15 +83,23 @@ class DummyPlatformView extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
const
String
viewType
=
'benchmarks/platform_views_layout/DummyPlatformView'
;
Stateful
Widget
nativeView
;
Widget
nativeView
;
if
(
Platform
.
isIOS
)
{
nativeView
=
const
UiKitView
(
viewType:
viewType
,
);
}
else
if
(
Platform
.
isAndroid
)
{
nativeView
=
const
AndroidView
(
viewType:
viewType
,
);
final
PlatformViewApp
app
=
PlatformViewApp
.
of
(
context
).
widget
;
assert
(
app
!=
null
);
if
(
app
.
enableHybridCompositionOnAndroid
)
{
nativeView
=
const
AndroidPlatformView
(
viewType:
viewType
,
);
}
else
{
nativeView
=
const
AndroidView
(
viewType:
viewType
,
);
}
}
else
{
assert
(
false
,
'Invalid platform'
);
}
...
...
dev/benchmarks/platform_views_layout/pubspec.yaml
View file @
b176042c
...
...
@@ -2,8 +2,7 @@ name: platform_views_layout
description
:
A benchmark for platform views.
environment
:
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
sdk
:
"
>=2.0.0-dev.68.0
<3.0.0"
sdk
:
"
>=2.2.0
<3.0.0"
dependencies
:
flutter
:
...
...
dev/benchmarks/platform_views_layout/test_driver/android_texture_scroll_perf.dart
0 → 100644
View file @
b176042c
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/widgets.dart'
;
import
'package:flutter_driver/driver_extension.dart'
;
import
'package:platform_views_layout/main.dart'
as
app
;
void
main
(
)
{
enableFlutterDriverExtension
();
runApp
(
const
app
.
PlatformViewApp
(
enableHybridCompositionOnAndroid:
false
,
)
);
}
dev/benchmarks/platform_views_layout/test_driver/android_view_scroll_perf.dart
0 → 100644
View file @
b176042c
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/widgets.dart'
;
import
'package:flutter_driver/driver_extension.dart'
;
import
'package:platform_views_layout/main.dart'
as
app
;
void
main
(
)
{
enableFlutterDriverExtension
();
runApp
(
const
app
.
PlatformViewApp
(
enableHybridCompositionOnAndroid:
true
,
)
);
}
dev/benchmarks/platform_views_layout/test_driver/scroll_perf.dart
→
dev/benchmarks/platform_views_layout/test_driver/
uikit_view_
scroll_perf.dart
View file @
b176042c
...
...
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/widgets.dart'
;
import
'package:flutter_driver/driver_extension.dart'
;
import
'package:platform_views_layout/main.dart'
as
app
;
void
main
(
)
{
enableFlutterDriverExtension
();
app
.
main
(
);
runApp
(
const
app
.
PlatformViewApp
()
);
}
dev/devicelab/bin/tasks/android_view_scroll_perf__timeline_summary.dart
0 → 100644
View file @
b176042c
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter_devicelab/tasks/perf_tests.dart'
;
import
'package:flutter_devicelab/framework/adb.dart'
;
import
'package:flutter_devicelab/framework/framework.dart'
;
Future
<
void
>
main
()
async
{
deviceOperatingSystem
=
DeviceOperatingSystem
.
android
;
await
task
(
createAndroidViewScrollPerfTest
());
}
dev/devicelab/bin/tasks/platform_views_scroll_perf__timeline_summary.dart
View file @
b176042c
...
...
@@ -10,5 +10,5 @@ import 'package:flutter_devicelab/framework/framework.dart';
Future
<
void
>
main
()
async
{
deviceOperatingSystem
=
DeviceOperatingSystem
.
android
;
await
task
(
create
PlatformViews
ScrollPerfTest
());
await
task
(
create
AndroidTexture
ScrollPerfTest
());
}
dev/devicelab/bin/tasks/platform_views_scroll_perf_ios__timeline_summary.dart
View file @
b176042c
...
...
@@ -10,5 +10,5 @@ import 'package:flutter_devicelab/framework/framework.dart';
Future
<
void
>
main
()
async
{
deviceOperatingSystem
=
DeviceOperatingSystem
.
ios
;
await
task
(
create
PlatformViews
ScrollPerfTest
());
await
task
(
create
UiKitView
ScrollPerfTest
());
}
dev/devicelab/lib/tasks/perf_tests.dart
View file @
b176042c
...
...
@@ -30,11 +30,30 @@ TaskFunction createTilesScrollPerfTest() {
).
run
;
}
TaskFunction
create
PlatformViews
ScrollPerfTest
(
)
{
TaskFunction
create
UiKitView
ScrollPerfTest
(
)
{
return
PerfTest
(
'
${flutterDirectory.path}
/dev/benchmarks/platform_views_layout'
,
'test_driver/scroll_perf.dart'
,
'test_driver/uikit_view_scroll_perf.dart'
,
'platform_views_scroll_perf'
,
testDriver:
'test_driver/scroll_perf_test.dart'
,
).
run
;
}
TaskFunction
createAndroidTextureScrollPerfTest
(
)
{
return
PerfTest
(
'
${flutterDirectory.path}
/dev/benchmarks/platform_views_layout'
,
'test_driver/android_texture_scroll_perf.dart'
,
'platform_views_scroll_perf'
,
testDriver:
'test_driver/scroll_perf_test.dart'
,
).
run
;
}
TaskFunction
createAndroidViewScrollPerfTest
(
)
{
return
PerfTest
(
'
${flutterDirectory.path}
/dev/benchmarks/platform_views_layout'
,
'test_driver/android_view_scroll_perf.dart'
,
'android_view_scroll_perf'
,
testDriver:
'test_driver/scroll_perf_test.dart'
,
).
run
;
}
...
...
@@ -235,15 +254,22 @@ class StartupTest {
/// performance.
class
PerfTest
{
const
PerfTest
(
this
.
testDirectory
,
this
.
testTarget
,
this
.
timelineFileName
,
{
this
.
needsMeasureCpuGPu
=
false
});
this
.
testDirectory
,
this
.
testTarget
,
this
.
timelineFileName
,
{
this
.
needsMeasureCpuGPu
=
false
,
this
.
testDriver
,
});
/// The directory where the app under test is defined.
final
String
testDirectory
;
/// The main entry-point file of the application, as run on the device.
final
String
testTarget
;
// The prefix name of the filename such as `<timelineFileName>.timeline_summary.json`.
final
String
timelineFileName
;
/// The test file to run on the host.
final
String
testDriver
;
/// Whether to collect CPU and GPU metrics.
final
bool
needsMeasureCpuGPu
;
Future
<
TaskResult
>
run
()
{
...
...
@@ -259,6 +285,8 @@ class PerfTest {
'--trace-startup'
,
// Enables "endless" timeline event buffering.
'-t'
,
testTarget
,
if
(
testDriver
!=
null
)
'--driver'
,
testDriver
,
'-d'
,
deviceId
,
]);
...
...
dev/devicelab/manifest.yaml
View file @
b176042c
...
...
@@ -152,6 +152,12 @@ tasks:
stage
:
devicelab
required_agent_capabilities
:
[
"
linux/android"
]
android_view_scroll_perf__timeline_summary
:
description
:
>
Measures the runtime performance of Android views in the platform view layout sample app on Android.
stage
:
devicelab
required_agent_capabilities
:
[
"
linux/android"
]
home_scroll_perf__timeline_summary
:
description
:
>
Measures the runtime performance of scrolling the material page in the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment