mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
![auto-submit[bot]](/assets/img/avatar_default.png)
<!-- start_original_pr_link --> Reverts: flutter/flutter#168914 <!-- end_original_pr_link --> <!-- start_initiating_author --> Initiated by: gaaclarke <!-- end_initiating_author --> <!-- start_revert_reason --> Reason for reverting: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20external_ui_integration_test_ios/16792/overview The external texture integration test is failing. Running the host app appeared to work but one of the driver asserts isn't working. <!-- 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 ## Changes since revert Device lab tests have been migrated to using the FlutterPlugin API for creating platform channels at process launch. ## Description fixes: https://github.com/flutter/flutter/issues/167267 design doc: https://docs.google.com/document/d/1ZfcQOs-UKRa9jsFG84-MTFeibZTLKCvPQLxF2eskx44/edit?tab=t.0 relands https://github.com/flutter/flutter/pull/168396 ## 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] <flutter-engprod-team@google.com>
77 lines
3.0 KiB
Objective-C
77 lines
3.0 KiB
Objective-C
// 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 "AppDelegate.h"
|
|
|
|
@interface AppDelegate ()
|
|
@property (atomic) uint64_t textureId;
|
|
@property (atomic) int framesProduced;
|
|
@property (atomic) int framesConsumed;
|
|
@property (atomic) int lastFrameConsumed;
|
|
@property (atomic) double startTime;
|
|
@property (atomic) double endTime;
|
|
@property (atomic) double frameRate;
|
|
@property (atomic) double frameStartTime;
|
|
@property (atomic) NSTimer* timer;
|
|
|
|
- (void)tick:(NSTimer*)timer;
|
|
@end
|
|
|
|
@implementation AppDelegate
|
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
FlutterViewController* flutterController =
|
|
(FlutterViewController*)self.window.rootViewController;
|
|
FlutterMethodChannel* channel =
|
|
[FlutterMethodChannel methodChannelWithName:@"texture"
|
|
binaryMessenger:flutterController];
|
|
[channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
|
if ([@"start" isEqualToString:call.method]) {
|
|
_framesProduced = 0;
|
|
_framesConsumed = 0;
|
|
_frameRate = 1.0 / [(NSNumber*) call.arguments intValue];
|
|
_timer = [NSTimer scheduledTimerWithTimeInterval:_frameRate
|
|
target:self
|
|
selector:@selector(tick:)
|
|
userInfo:nil
|
|
repeats:YES];
|
|
_startTime = [[NSDate date] timeIntervalSince1970];
|
|
result(nil);
|
|
} else if ([@"stop" isEqualToString:call.method]) {
|
|
[_timer invalidate];
|
|
_endTime = [[NSDate date] timeIntervalSince1970];
|
|
result(nil);
|
|
} else if ([@"getProducedFrameRate" isEqualToString:call.method]) {
|
|
result(@(_framesProduced / (_endTime - _startTime)));
|
|
} else if ([@"getConsumedFrameRate" isEqualToString:call.method]) {
|
|
result(@(_framesConsumed / (_endTime - _startTime)));
|
|
} else {
|
|
result(FlutterMethodNotImplemented);
|
|
}
|
|
}];
|
|
_textureId = [flutterController registerTexture:self];
|
|
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
|
}
|
|
|
|
- (void)tick:(NSTimer*)timer {
|
|
FlutterViewController* flutterController =
|
|
(FlutterViewController*)self.window.rootViewController;
|
|
[flutterController textureFrameAvailable:_textureId];
|
|
_frameStartTime = [[NSDate date] timeIntervalSince1970];
|
|
// We just pretend to be producing a frame.
|
|
_framesProduced++;
|
|
}
|
|
|
|
- (CVPixelBufferRef)copyPixelBuffer {
|
|
double now = [[NSDate date] timeIntervalSince1970];
|
|
if (now < _frameStartTime
|
|
|| _frameStartTime + _frameRate < now
|
|
|| _framesProduced == _lastFrameConsumed) return nil;
|
|
_framesConsumed++;
|
|
_lastFrameConsumed = _framesProduced;
|
|
// We just pretend to be handing over the produced frame to the consumer.
|
|
return nil;
|
|
}
|
|
@end
|