Skip to content

Commit

Permalink
Platform view devicelab ad banner scroll list real ads (#145239)
Browse files Browse the repository at this point in the history
Reland flutter/flutter#144745, which was reverted due to a the Android app ads not being set up correctly, crashing on launch: flutter/flutter#145228

Add the missing [`com.google.android.gms.ads.APPLICATION_ID` `meta-data` tag](https://developers.google.com/admob/android/quick-start#import_the_mobile_ads_sdk) to the manifest.

Validated both `platform_views_scroll_perf__timeline_summary` and `platform_views_scroll_perf_impeller__timeline_summary` ran locally on an Android emulator.

Successful presubmit runs:
https://ci.chromium.org/ui/p/flutter/builders/try/Linux_pixel_7pro%20platform_views_scroll_perf__timeline_summary/4/overview
https://ci.chromium.org/ui/p/flutter/builders/try/Linux_pixel_7pro%20platform_views_scroll_perf_impeller__timeline_summary/4/overview

Original commit message:
_________
This benchmark is to measure the platform view performance improvement. 

It is similar to https://github.com/lucalooz/flutter_ads_list_perf

There's still a pending issue flutter/flutter#144339

Fixes flutter/flutter#143534
Fixes flutter/flutter#143257
  • Loading branch information
jmagman authored Mar 16, 2024
1 parent 7599666 commit a2678be
Show file tree
Hide file tree
Showing 20 changed files with 560 additions and 33 deletions.
10 changes: 10 additions & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4627,6 +4627,16 @@ targets:
["devicelab", "ios", "mac"]
task_name: platform_views_scroll_perf_ios__timeline_summary

- name: Mac_ios platform_views_scroll_perf_ad_banners__timeline_summary
recipe: devicelab/devicelab_drone
presubmit: false
bringup: true
timeout: 60
properties:
tags: >
["devicelab", "ios", "mac"]
task_name: platform_views_scroll_perf_ad_banners__timeline_summary

- name: Mac_ios platform_views_scroll_perf_non_intersecting_impeller_ios__timeline_summary
recipe: devicelab/devicelab_drone
presubmit: false
Expand Down
1 change: 1 addition & 0 deletions TESTOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
/dev/devicelab/bin/tasks/platform_channels_benchmarks_ios.dart @gaaclarke @flutter/engine
/dev/devicelab/bin/tasks/platform_interaction_test_ios.dart @hellohuanlin @flutter/engine
/dev/devicelab/bin/tasks/platform_view_ios__start_up.dart @stuartmorgan @flutter/plugin
/dev/devicelab/bin/tasks/platform_views_scroll_perf_ad_banners__timeline_summary.dart @hellohuanlin @flutter/engine
/dev/devicelab/bin/tasks/platform_views_scroll_perf_ios__timeline_summary.dart @hellohuanlin @flutter/engine
/dev/devicelab/bin/tasks/platform_views_scroll_perf_non_intersecting_impeller_ios__timeline_summary.dart @jonahwilliams @flutter/engine
/dev/devicelab/bin/tasks/post_backdrop_filter_perf_ios__timeline_summary.dart @hellohuanlin @flutter/engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ found in the LICENSE file. -->
</intent-filter>
</activity>
<meta-data android:name="flutterEmbedding" android:value="2"/>
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
</application>
</manifest>
98 changes: 76 additions & 22 deletions dev/benchmarks/platform_views_layout/android/project-app.lockfile

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
38 changes: 38 additions & 0 deletions dev/benchmarks/platform_views_layout/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
4552BF1971CFF555ACB2839A /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BD993316F35385497F75FF6C /* libPods-Runner.a */; };
647B792C24207B8900ABA501 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 647B792B24207B8900ABA501 /* AppDelegate.m */; };
647B792F24207D1600ABA501 /* DummyPlatformView.m in Sources */ = {isa = PBXBuildFile; fileRef = 647B792E24207D1600ABA501 /* DummyPlatformView.m */; };
647B793224208A4200ABA501 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 647B793024208A4200ABA501 /* GeneratedPluginRegistrant.m */; };
Expand All @@ -31,6 +32,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0F4D3146B7B6DF07E43DC73C /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3269CF3CF6F192082C33C163 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
5E91F24FF1A398625C9C0FA5 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
647B792824207ADD00ABA501 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
647B792B24207B8900ABA501 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
647B792D24207CC400ABA501 /* DummyPlatformView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DummyPlatformView.h; sourceTree = "<group>"; };
Expand All @@ -47,19 +51,39 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BD993316F35385497F75FF6C /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4552BF1971CFF555ACB2839A /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
0093AEB0458530A026D4EDDD /* Frameworks */ = {
isa = PBXGroup;
children = (
BD993316F35385497F75FF6C /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
3B86C3C30DA7CC47EE4FB68E /* Pods */ = {
isa = PBXGroup;
children = (
3269CF3CF6F192082C33C163 /* Pods-Runner.debug.xcconfig */,
0F4D3146B7B6DF07E43DC73C /* Pods-Runner.release.xcconfig */,
5E91F24FF1A398625C9C0FA5 /* Pods-Runner.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
Expand All @@ -77,6 +101,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
3B86C3C30DA7CC47EE4FB68E /* Pods */,
0093AEB0458530A026D4EDDD /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -121,12 +147,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
F9890346AACD48B6C9FEE2A0 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
9A0E2E29949C30C54EBF3099 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -215,6 +243,45 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
9A0E2E29949C30C54EBF3099 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
F9890346AACD48B6C9FEE2A0 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -307,6 +374,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -430,7 +498,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = S8QB4VV633;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -449,6 +517,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions dev/benchmarks/platform_views_layout/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand All @@ -20,8 +22,12 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -43,9 +49,5 @@
<true/>
<key>io.flutter.metal_preview</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
67 changes: 67 additions & 0 deletions dev/benchmarks/platform_views_layout/lib/main_ad_banners.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// 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:io';

import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';

void main() {
runApp(
const PlatformViewApp()
);
}

class PlatformViewApp extends StatefulWidget {
const PlatformViewApp({
super.key,
});

@override
PlatformViewAppState createState() => PlatformViewAppState();
}

class PlatformViewAppState extends State<PlatformViewApp> {

AdWidget _getBannerWidget() {
// Test IDs from Admob:
// https://developers.google.com/admob/ios/test-ads
// https://developers.google.com/admob/android/test-ads
final String bannerId = Platform.isAndroid
? 'ca-app-pub-3940256099942544/6300978111'
: 'ca-app-pub-3940256099942544/2934735716';
final BannerAd bannerAd = BannerAd(
adUnitId: bannerId,
request: const AdRequest(),
size: AdSize.banner,
listener: const BannerAdListener(),
);
bannerAd.load();
return AdWidget(ad: bannerAd);
}

@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.light(),
title: 'Advanced Layout',
home: Scaffold(
appBar: AppBar(title: const Text('Platform View Ad Banners')),
body: ListView.builder(
key: const Key('platform-views-scroll'), // This key is used by the driver test.
itemCount: 250,
itemBuilder: (BuildContext context, int index) {
return index.isEven
// Use 320x50 Admob standard banner size.
? SizedBox(width: 320, height: 50, child: _getBannerWidget())
// Adjust the height to control number of platform views on screen.
// TODO(hellohuanlin): Having more than 5 banners on screen causes an unknown crash.
// See: https://github.com/flutter/flutter/issues/144339
: const SizedBox(height: 150, child: ColoredBox(color: Colors.yellow));
},
),
),
);
}
}
9 changes: 7 additions & 2 deletions dev/benchmarks/platform_views_layout/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
sdk: flutter
flutter_driver:
sdk: flutter

google_mobile_ads: 4.0.0
# To change the version of the gallery assets, edit
# //packages/flutter_tools/lib/src/commands/update_packages.dart
# and run
Expand All @@ -25,6 +25,7 @@ dependencies:
material_color_utilities: 0.8.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
meta: 1.12.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
path: 1.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
plugin_platform_interface: 2.1.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
stack_trace: 1.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
stream_channel: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
Expand All @@ -35,6 +36,10 @@ dependencies:
vector_math: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
vm_service: 14.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
webdriver: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
webview_flutter: 4.7.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
webview_flutter_android: 3.15.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
webview_flutter_platform_interface: 2.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
webview_flutter_wkwebview: 3.12.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"

dev_dependencies:
flutter_test:
Expand Down Expand Up @@ -84,4 +89,4 @@ flutter:
- packages/flutter_gallery_assets/people/square/ali.png
- packages/flutter_gallery_assets/places/india_chettinad_silk_maker.png

# PUBSPEC CHECKSUM: 76bc
# PUBSPEC CHECKSUM: c673
Loading

0 comments on commit a2678be

Please sign in to comment.