Skip to content

Commit 9d6fbb7

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/replay-bitmap-transfer
2 parents 7f1fbf4 + ec50b21 commit 9d6fbb7

File tree

135 files changed

+4966
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+4966
-5
lines changed

flutter/.pubignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.vscode/
2+
microbenchmarks

flutter/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ include: package:flutter_lints/flutter.yaml
33
analyzer:
44
exclude:
55
- test/*.mocks.dart
6+
- microbenchmarks/**
67
language:
78
strict-casts: true
89
strict-inference: true

flutter/lib/src/screenshot/screenshot.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Screenshot {
1414
final Flow flow;
1515
Future<ByteData>? _rawRgbaData;
1616
Future<ByteData>? _pngData;
17+
bool _disposed = false;
1718

1819
Screenshot(this._image, this.timestamp, this.flow);
1920
Screenshot._cloned(
@@ -49,12 +50,19 @@ class Screenshot {
4950
}
5051

5152
Screenshot clone() {
52-
assert(!_image.debugDisposed);
53+
assert(!_disposed, 'Cannot clone a disposed screenshot');
5354
return Screenshot._cloned(
5455
_image.clone(), timestamp, flow, _rawRgbaData, _pngData);
5556
}
5657

57-
void dispose() => _image.dispose();
58+
void dispose() {
59+
if (!_disposed) {
60+
_disposed = true;
61+
_image.dispose();
62+
_rawRgbaData = null;
63+
_pngData = null;
64+
}
65+
}
5866

5967
/// Efficiently compares two memory regions for data equality..
6068
@visibleForTesting

flutter/lib/src/screenshot/stabilizer.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class ScreenshotStabilizer<R> {
6565
return;
6666
}
6767

68-
final prevScreenshot = _previousScreenshot;
68+
var prevScreenshot = _previousScreenshot;
6969
try {
7070
_previousScreenshot = screenshot.clone();
7171
if (prevScreenshot != null &&
@@ -85,8 +85,18 @@ class ScreenshotStabilizer<R> {
8585
return;
8686
}
8787
} finally {
88+
// [prevScreenshot] and [screenshot] are unnecessary after this line.
8889
// Note: we need to dispose (free the memory) before recursion.
90+
// Also, we need to reset the variable to null so that the whole object
91+
// can be garbage collected.
8992
prevScreenshot?.dispose();
93+
prevScreenshot = null;
94+
// Note: while the caller will also do `screenshot.dispose()`,
95+
// it would be a problem in a long recursion because we only return
96+
// from this function when the screenshot is ultimately stable.
97+
// At that point, the caller would have accumulated a lot of screenshots
98+
// on stack. This would lead to OOM.
99+
screenshot.dispose();
90100
}
91101

92102
if (maxTries != null && _tries >= maxTries!) {

flutter/microbenchmarks/.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.build/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.swiftpm/
13+
migrate_working_dir/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# The .vscode folder contains launch configuration and tasks you configure in
22+
# VS Code which you may wish to be included in version control, so this line
23+
# is commented out by default.
24+
#.vscode/
25+
26+
# Flutter/Dart/Pub related
27+
**/doc/api/
28+
**/ios/Flutter/.last_build_id
29+
.dart_tool/
30+
.flutter-plugins
31+
.flutter-plugins-dependencies
32+
.pub-cache/
33+
.pub/
34+
/build/
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Android Studio will place build artifacts here
43+
/android/app/debug
44+
/android/app/profile
45+
/android/app/release

flutter/microbenchmarks/.metadata

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "8495dee1fd4aacbe9de707e7581203232f591b2f"
8+
channel: "stable"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
17+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
18+
- platform: android
19+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
20+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
21+
- platform: ios
22+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
23+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
24+
- platform: linux
25+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
26+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
27+
- platform: macos
28+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
29+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
30+
- platform: web
31+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
32+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
33+
- platform: windows
34+
create_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
35+
base_revision: 8495dee1fd4aacbe9de707e7581203232f591b2f
36+
37+
# User provided section
38+
39+
# List of Local paths (relative to this file) that should be
40+
# ignored by the migrate tool.
41+
#
42+
# Files that are not part of the templates will be ignored by default.
43+
unmanaged_files:
44+
- 'lib/main.dart'
45+
- 'ios/Runner.xcodeproj/project.pbxproj'

flutter/microbenchmarks/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Microbenchmarks
2+
3+
To run these benchmarks on a device, execute:
4+
```
5+
flutter run --profile -d <device>
6+
```
7+
or
8+
```
9+
flutter run --release -d <device>
10+
```
11+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
analyzer:
4+
errors:
5+
avoid_print: ignore
6+
implementation_imports: ignore
7+
invalid_use_of_internal_member: ignore
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
gradle-wrapper.jar
2+
/.gradle
3+
/captures/
4+
/gradlew
5+
/gradlew.bat
6+
/local.properties
7+
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/to/reference-keystore
11+
key.properties
12+
**/*.keystore
13+
**/*.jks
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5+
id "dev.flutter.flutter-gradle-plugin"
6+
}
7+
8+
android {
9+
namespace = "com.example.microbenchmarks"
10+
compileSdk = flutter.compileSdkVersion
11+
ndkVersion = flutter.ndkVersion
12+
13+
compileOptions {
14+
sourceCompatibility = JavaVersion.VERSION_1_8
15+
targetCompatibility = JavaVersion.VERSION_1_8
16+
}
17+
18+
kotlinOptions {
19+
jvmTarget = JavaVersion.VERSION_1_8
20+
}
21+
22+
defaultConfig {
23+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
24+
applicationId = "com.example.microbenchmarks"
25+
// You can update the following values to match your application needs.
26+
// For more information, see: https://flutter.dev/to/review-gradle-config.
27+
minSdk = flutter.minSdkVersion
28+
targetSdk = flutter.targetSdkVersion
29+
versionCode = flutter.versionCode
30+
versionName = flutter.versionName
31+
}
32+
33+
buildTypes {
34+
release {
35+
// TODO: Add your own signing config for the release build.
36+
// Signing with the debug keys for now, so `flutter run --release` works.
37+
signingConfig = signingConfigs.debug
38+
}
39+
}
40+
}
41+
42+
flutter {
43+
source = "../.."
44+
}

0 commit comments

Comments
 (0)