Skip to content

Commit 85564cb

Browse files
auto-submit[bot]auto-submit[bot]
andauthored
Reverts "[Reland2] Implements UISceneDelegate dynamically w/ FlutterLaunchEngine (flutter#169276)" (flutter#169347)
<!-- start_original_pr_link --> Reverts: flutter#169276 <!-- end_original_pr_link --> <!-- start_initiating_author --> Initiated by: vashworth <!-- end_initiating_author --> <!-- start_revert_reason --> Reason for reverting: Causing google testing failures <!-- end_revert_reason --> <!-- start_original_pr_author --> Original PR Author: gaaclarke <!-- end_original_pr_author --> <!-- start_reviewers --> Reviewed By: {vashworth} <!-- end_reviewers --> <!-- start_revert_body --> This change reverts the following previous change: ## **BREAKING CHANGE** Adopting Apple's UISceneDelegate protocol shifts the initialization order of apps. For the common cases we've made sure they will work without change. The one case that will require a change is any app that in `-[UIApplicateDelegate didFinishLaunchingWithOptions:]` assumes that `UIApplicationDelegate.window.rootViewController` is a `FlutterViewController` instance. This is sometimes done to register platform channels directly on the `FlutterViewController`. Instead users should use the `FlutterPluginRegistry` API's to create platform channels in `-[UIApplicateDelegate didFinishLaunchingWithOptions:]`, like `FlutterPlugin`s do. An example can be seen here: https://github.com/flutter/flutter/pull/168914/files#diff-9f59c5248b58124beca7e290a57646023cda3ca024607092c6c6932606ce16ee In extreme cases, like bespoke test harnesses, the startup logic can be moved to `-[FlutterViewController awakeFromNib]` in a FlutterViewController subclass. An example can be seen here: https://github.com/flutter/flutter/pull/169276/files#diff-dbe39c23a0a380447b90b7559a878dae8564616e0875c4ef0d9e99e02b91adac ## Changes since revert I changed the init in `//dev/integration_tests/external_textures` from the UIApplicationDelegate to the FlutterViewController's awakeFromNib. This is a more appropriate place for initialization post-UISceneDelegate since it avoids the launch engine altogether. I tried avoiding to make the big change to prove we could do a small change to migrate that project. I don't think this big refactor is indicative of what users will experience. There was a timing assumption in the integration test that required not using the launch engine at all. ## Description fixes: flutter#167267 design doc: https://docs.google.com/document/d/1ZfcQOs-UKRa9jsFG84-MTFeibZTLKCvPQLxF2eskx44/edit?tab=t.0 relands flutter#168396 relands flutter#168914 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- end_revert_body --> Co-authored-by: auto-submit[bot] <[email protected]>
1 parent d5ae783 commit 85564cb

File tree

25 files changed

+112
-505
lines changed

25 files changed

+112
-505
lines changed

dev/integration_tests/channels/ios/Runner/AppDelegate.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,36 +86,38 @@ @implementation AppDelegate
8686
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8787
[GeneratedPluginRegistrant registerWithRegistry:self];
8888
// Override point for customization after application launch.
89-
id<FlutterPluginRegistrar> registrar = [self registrarForPlugin:@"platform-channel-test"];
89+
FlutterViewController *flutterController =
90+
(FlutterViewController *)self.window.rootViewController;
91+
9092
ExtendedReaderWriter* extendedReaderWriter = [ExtendedReaderWriter new];
9193
[self setupMessagingHandshakeOnChannel:
9294
[FlutterBasicMessageChannel messageChannelWithName:@"binary-msg"
93-
binaryMessenger:registrar.messenger
95+
binaryMessenger:flutterController
9496
codec:[FlutterBinaryCodec sharedInstance]]];
9597
[self setupMessagingHandshakeOnChannel:
9698
[FlutterBasicMessageChannel messageChannelWithName:@"string-msg"
97-
binaryMessenger:registrar.messenger
99+
binaryMessenger:flutterController
98100
codec:[FlutterStringCodec sharedInstance]]];
99101
[self setupMessagingHandshakeOnChannel:
100102
[FlutterBasicMessageChannel messageChannelWithName:@"json-msg"
101-
binaryMessenger:registrar.messenger
103+
binaryMessenger:flutterController
102104
codec:[FlutterJSONMessageCodec sharedInstance]]];
103105
[self setupMessagingHandshakeOnChannel:
104106
[FlutterBasicMessageChannel messageChannelWithName:@"std-msg"
105-
binaryMessenger:registrar.messenger
107+
binaryMessenger:flutterController
106108
codec:[FlutterStandardMessageCodec codecWithReaderWriter:extendedReaderWriter]]];
107109
[self setupMethodCallSuccessHandshakeOnChannel:
108110
[FlutterMethodChannel methodChannelWithName:@"json-method"
109-
binaryMessenger:registrar.messenger
111+
binaryMessenger:flutterController
110112
codec:[FlutterJSONMethodCodec sharedInstance]]];
111113
[self setupMethodCallSuccessHandshakeOnChannel:
112114
[FlutterMethodChannel methodChannelWithName:@"std-method"
113-
binaryMessenger:registrar.messenger
115+
binaryMessenger:flutterController
114116
codec:[FlutterStandardMethodCodec codecWithReaderWriter:extendedReaderWriter]]];
115117

116118
[[FlutterBasicMessageChannel
117119
messageChannelWithName:@"std-echo"
118-
binaryMessenger:registrar.messenger
120+
binaryMessenger:flutterController
119121
codec:[FlutterStandardMessageCodec
120122
codecWithReaderWriter:extendedReaderWriter]]
121123
setMessageHandler:^(id message, FlutterReply reply) {

dev/integration_tests/external_textures/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
0D569A532DDF895D00F24F69 /* TextureViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D569A522DDF895D00F24F69 /* TextureViewController.m */; };
1110
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1211
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1312
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
@@ -29,8 +28,6 @@
2928
/* End PBXCopyFilesBuildPhase section */
3029

3130
/* Begin PBXFileReference section */
32-
0D569A522DDF895D00F24F69 /* TextureViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TextureViewController.m; sourceTree = "<group>"; };
33-
0D569A542DDF896B00F24F69 /* TextureViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextureViewController.h; sourceTree = "<group>"; };
3431
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3532
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
3633
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -92,8 +89,6 @@
9289
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
9390
97C147021CF9000F007C117D /* Info.plist */,
9491
97C146F11CF9000F007C117D /* Supporting Files */,
95-
0D569A522DDF895D00F24F69 /* TextureViewController.m */,
96-
0D569A542DDF896B00F24F69 /* TextureViewController.h */,
9792
);
9893
path = Runner;
9994
sourceTree = "<group>";
@@ -215,7 +210,6 @@
215210
files = (
216211
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
217212
97C146F31CF9000F007C117D /* main.m in Sources */,
218-
0D569A532DDF895D00F24F69 /* TextureViewController.m in Sources */,
219213
);
220214
runOnlyForDeploymentPostprocessing = 0;
221215
};
@@ -287,13 +281,9 @@
287281
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
288282
buildSettings = {
289283
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
290-
DEVELOPMENT_TEAM = S8QB4VV633;
291284
ENABLE_BITCODE = NO;
292285
INFOPLIST_FILE = Runner/Info.plist;
293-
LD_RUNPATH_SEARCH_PATHS = (
294-
"$(inherited)",
295-
"@executable_path/Frameworks",
296-
);
286+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
297287
PRODUCT_BUNDLE_IDENTIFIER = io.flutter.externalUi;
298288
PRODUCT_NAME = "$(TARGET_NAME)";
299289
};
@@ -392,13 +382,9 @@
392382
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
393383
buildSettings = {
394384
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
395-
DEVELOPMENT_TEAM = S8QB4VV633;
396385
ENABLE_BITCODE = NO;
397386
INFOPLIST_FILE = Runner/Info.plist;
398-
LD_RUNPATH_SEARCH_PATHS = (
399-
"$(inherited)",
400-
"@executable_path/Frameworks",
401-
);
387+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
402388
PRODUCT_BUNDLE_IDENTIFIER = io.flutter.externalUi;
403389
PRODUCT_NAME = "$(TARGET_NAME)";
404390
};
@@ -409,13 +395,9 @@
409395
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
410396
buildSettings = {
411397
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
412-
DEVELOPMENT_TEAM = S8QB4VV633;
413398
ENABLE_BITCODE = NO;
414399
INFOPLIST_FILE = Runner/Info.plist;
415-
LD_RUNPATH_SEARCH_PATHS = (
416-
"$(inherited)",
417-
"@executable_path/Frameworks",
418-
);
400+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
419401
PRODUCT_BUNDLE_IDENTIFIER = io.flutter.externalUi;
420402
PRODUCT_NAME = "$(TARGET_NAME)";
421403
};

dev/integration_tests/external_textures/ios/Runner/AppDelegate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
#import <UIKit/UIKit.h>
66
#import <Flutter/Flutter.h>
77

8-
@interface AppDelegate : FlutterAppDelegate
8+
@interface AppDelegate : FlutterAppDelegate<FlutterTexture>
9+
910
@end

dev/integration_tests/external_textures/ios/Runner/AppDelegate.m

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,73 @@
44

55
#import "AppDelegate.h"
66

7+
@interface AppDelegate ()
8+
@property (atomic) uint64_t textureId;
9+
@property (atomic) int framesProduced;
10+
@property (atomic) int framesConsumed;
11+
@property (atomic) int lastFrameConsumed;
12+
@property (atomic) double startTime;
13+
@property (atomic) double endTime;
14+
@property (atomic) double frameRate;
15+
@property (atomic) double frameStartTime;
16+
@property (atomic) NSTimer* timer;
17+
18+
- (void)tick:(NSTimer*)timer;
19+
@end
20+
721
@implementation AppDelegate
22+
23+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
24+
FlutterViewController* flutterController =
25+
(FlutterViewController*)self.window.rootViewController;
26+
FlutterMethodChannel* channel =
27+
[FlutterMethodChannel methodChannelWithName:@"texture"
28+
binaryMessenger:flutterController];
29+
[channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
30+
if ([@"start" isEqualToString:call.method]) {
31+
_framesProduced = 0;
32+
_framesConsumed = 0;
33+
_frameRate = 1.0 / [(NSNumber*) call.arguments intValue];
34+
_timer = [NSTimer scheduledTimerWithTimeInterval:_frameRate
35+
target:self
36+
selector:@selector(tick:)
37+
userInfo:nil
38+
repeats:YES];
39+
_startTime = [[NSDate date] timeIntervalSince1970];
40+
result(nil);
41+
} else if ([@"stop" isEqualToString:call.method]) {
42+
[_timer invalidate];
43+
_endTime = [[NSDate date] timeIntervalSince1970];
44+
result(nil);
45+
} else if ([@"getProducedFrameRate" isEqualToString:call.method]) {
46+
result(@(_framesProduced / (_endTime - _startTime)));
47+
} else if ([@"getConsumedFrameRate" isEqualToString:call.method]) {
48+
result(@(_framesConsumed / (_endTime - _startTime)));
49+
} else {
50+
result(FlutterMethodNotImplemented);
51+
}
52+
}];
53+
_textureId = [flutterController registerTexture:self];
54+
return [super application:application didFinishLaunchingWithOptions:launchOptions];
55+
}
56+
57+
- (void)tick:(NSTimer*)timer {
58+
FlutterViewController* flutterController =
59+
(FlutterViewController*)self.window.rootViewController;
60+
[flutterController textureFrameAvailable:_textureId];
61+
_frameStartTime = [[NSDate date] timeIntervalSince1970];
62+
// We just pretend to be producing a frame.
63+
_framesProduced++;
64+
}
65+
66+
- (CVPixelBufferRef)copyPixelBuffer {
67+
double now = [[NSDate date] timeIntervalSince1970];
68+
if (now < _frameStartTime
69+
|| _frameStartTime + _frameRate < now
70+
|| _framesProduced == _lastFrameConsumed) return nil;
71+
_framesConsumed++;
72+
_lastFrameConsumed = _framesProduced;
73+
// We just pretend to be handing over the produced frame to the consumer.
74+
return nil;
75+
}
876
@end
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23727" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="retina6_12" orientation="portrait" appearance="light"/>
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
43
<dependencies>
54
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23721"/>
7-
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
86
</dependencies>
97
<scenes>
10-
<!--Texture View Controller-->
8+
<!--Flutter View Controller-->
119
<scene sceneID="tne-QT-ifu">
1210
<objects>
13-
<viewController id="BYZ-38-t0r" customClass="TextureViewController" sceneMemberID="viewController">
11+
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
1412
<layoutGuides>
1513
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
1614
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
1715
</layoutGuides>
1816
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
19-
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
17+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
2018
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
21-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
19+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
2220
</view>
2321
</viewController>
2422
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2523
</objects>
26-
<point key="canvasLocation" x="132" y="-34"/>
2724
</scene>
2825
</scenes>
2926
</document>

dev/integration_tests/external_textures/ios/Runner/TextureViewController.h

Lines changed: 0 additions & 8 deletions
This file was deleted.

dev/integration_tests/external_textures/ios/Runner/TextureViewController.m

Lines changed: 0 additions & 75 deletions
This file was deleted.

engine/src/flutter/ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52778,7 +52778,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/ConnectionCo
5277852778
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FakeUIPressProxy.swift + ../../../flutter/LICENSE
5277952779
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm + ../../../flutter/LICENSE
5278052780
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm + ../../../flutter/LICENSE
52781-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate_Internal.h + ../../../flutter/LICENSE
5278252781
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate_Test.h + ../../../flutter/LICENSE
5278352782
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache.mm + ../../../flutter/LICENSE
5278452783
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h + ../../../flutter/LICENSE
@@ -52809,9 +52808,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySe
5280952808
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h + ../../../flutter/LICENSE
5281052809
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm + ../../../flutter/LICENSE
5281152810
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManagerTest.mm + ../../../flutter/LICENSE
52812-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.h + ../../../flutter/LICENSE
52813-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.m + ../../../flutter/LICENSE
52814-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngineTest.mm + ../../../flutter/LICENSE
5281552811
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayer.h + ../../../flutter/LICENSE
5281652812
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayer.mm + ../../../flutter/LICENSE
5281752813
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm + ../../../flutter/LICENSE
@@ -55808,7 +55804,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/ConnectionColl
5580855804
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FakeUIPressProxy.swift
5580955805
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
5581055806
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm
55811-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate_Internal.h
5581255807
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate_Test.h
5581355808
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache.mm
5581455809
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h
@@ -55839,9 +55834,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySeco
5583955834
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h
5584055835
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm
5584155836
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManagerTest.mm
55842-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.h
55843-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.m
55844-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngineTest.mm
5584555837
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayer.h
5584655838
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayer.mm
5584755839
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm

0 commit comments

Comments
 (0)