-
Notifications
You must be signed in to change notification settings - Fork 29.8k
[ios]: Warning for FlutterAppDelegate.window.rootViewController in launch functions #169166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ios]: Warning for FlutterAppDelegate.window.rootViewController in launch functions #169166
Conversation
FlutterAppDelegate.window.rootViewController in launch functions.
ffb0565 to
01d385a
Compare
|
@vashworth This behaves like we'd want it but isn't quite done. We have to make a decision about how to wrap this up:
Let me know what you are thinking. |
Okay here's what I would do I would change this flutter/packages/flutter_tools/bin/xcode_backend.dart Lines 123 to 131 in e78b434
to if (resultStderr.isNotEmpty) {
final StringBuffer errorOutput = StringBuffer();
if (result.exitCode != 0) {
// "error:" prefix makes this show up as an Xcode compilation error.
errorOutput.write('error: ');
}
errorOutput.write(resultStderr);
echoError(errorOutput.toString());
+ // Stream stderr to the Flutter build process.
+ // When in verbose mode, `echoError` above will show the logs. So only
+ // stream if not in verbose mode to avoid duplicate logs.
+ // Also, only stream if exitCode is 0 since errors are handled separately
+ // by the tool on failure.
+ if (!verbose && exitCode == 0) {
+ streamOutput(errorOutput.toString());
+ }
}And change this flutter/packages/flutter_tools/lib/src/ios/mac.dart Lines 428 to 435 in e78b434
to } else {
+ if (!globals.logger.isVerbose) {
+ if (line.contains('error:')) {
+ globals.printError(line);
+ } else if (line.contains('warning:')) {
+ globals.printWarning(line);
+ }
+ continue;
+ }
initialBuildStatus?.cancel();
initialBuildStatus = null;
buildSubStatus = globals.logger.startProgress(
line,
progressIndicatorPadding: kDefaultStatusPadding - 7,
);
}I tested it out and that works for me, but let me know if you run into problems |
|
@vashworth okay, so forwarding warning print statements to stdout only for that subprocess and avoiding the xcresult altogether. That works except it chops off the extra context that follows the warning, all the stuff in the |
a2e149e to
d16d2f9
Compare
|
@vashworth this is ready to review now. Let me know if you have a good idea on a more complete integration test. |
|
friendly ping @hellohuanlin @vashworth |
I think you can do something like this for integration testing: Basically, create an app, alter the AppDelegate to have the rootViewController code, then build (either flutter build or xcodebuild or both) and check the stdout/stderr for the warnings |
| await _checkForLaunchRootViewControllerAccessDeprecation( | ||
| logger, | ||
| file, | ||
| RegExp('self.*?window.*?rootViewController'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also check if they're casting it to a FlutterViewController.
| RegExp('self.*?window.*?rootViewController'), | |
| RegExp('FlutterViewController.*?self.*?window.*?rootViewController'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so because in objc id is a valid type. I'm also concerned about newlines:
id viewController = self.window.rootViewController;FlutterViewController* vc = (FlutterViewController*)
self.window.rootViewController;| logger, | ||
| file, | ||
| RegExp('self.*?window.*?rootViewController'), | ||
| RegExp('^}'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we check for any terminator? We don't know if they're properly formatted. I'd lean on the side of catching fewer than catching too many, but I don't feel too strongly about it.
| RegExp('^}'), | |
| RegExp('}'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caret is necessary to identify the whole block for the method (the caret means matching the beginning of the line).
| await _checkForLaunchRootViewControllerAccessDeprecation( | ||
| logger, | ||
| file, | ||
| 'window?.rootViewController', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 'window?.rootViewController', | |
| 'window?.rootViewController.*?FlutterViewController', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't do this because I wanted to catch things like this:
analyticsLibrary.viewController = window?.rootViewController| globals.printWarning(line); | ||
| inNoteBlock = false; | ||
| } else if (inWarningBlock) { | ||
| if (line.startsWith(RegExp(r'\s+?note[:]'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (line.startsWith(RegExp(r'\s+?note[:]'))) { | |
| if (line.startsWith(RegExp(r'\s*?note[:]\s*?$'))) { |
Notes can also be a single line. This regex shouldn't match if it is
note: hello world
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now this is the only instance of printing notes in our script and we don't ever do that. What I found was that Xcode's parser was ripping out the note: line. I spent a couple hours fiddling with it and this was the best I could get. I think we should have the more specific regex for now and only change it if we need to support it in the future.
| inNoteBlock = false; | ||
| } else if (inWarningBlock) { | ||
| if (line.startsWith(RegExp(r'\s+?note[:]'))) { | ||
| // Xcode doesn't echo this, so we don't. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xcode doesn't echo notes? I'm pretty sure it does...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That "note:" line in particular it doesn't. I fought with it for a while. It's a black box.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Victoria Ashworth <15619084+vashworth@users.noreply.github.com>
Co-authored-by: Victoria Ashworth <15619084+vashworth@users.noreply.github.com>
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…ller in launch functions (flutter/flutter#169166)
|
Hello @gaaclarke, I wonder if it's required to change anything in our apps now since this merge? I previously used master and everything was fine but since this commit is included my app works in debug mode - but instantly crashes in release mode. According to https://docs.google.com/document/d/1ZfcQOs-UKRa9jsFG84-MTFeibZTLKCvPQLxF2eskx44/edit?tab=t.0 I understood it like the info.plist has to be updated to include: and the AppDelegate.swift file needs to be changed from: to This swift code change resulted in an Any help or hint would be much appreciated, thanks a lot. More information: FPPDeviceInfoPlusPlugin, FLTFirebaseAnalyticsPlugin, FLTFirebaseCorePlugin, SmartlookPlugin, GeolocatorPlugin, InAppReviewPlugin, MapboxMapsPlugin, FPPPackageInfoPlusPlugin, PathProviderPlugin, PermissionHandlerPlugin, SentryFlutterPlugin, FPPSharePlusPlugin, SqflitePlugin, SuperwallkitFlutterPlugin, URLLauncherPlugin Flutter version: Flutter 3.33.0-1.0.pre.380 • channel master • https://github.com/flutter/flutter.git |
It depends, maybe not. There is a PR open for the migration guide: flutter/website#12082 Please give that a look and hopefully that clears everything up for you. |
Spent a couple of hours trying to find the reason for the crash and turned it out it's unrelated to this topic. Created a new ticket: #170038 I will try to provide more information soon. Thanks for your quick answer anyway. |
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)
…er in launch functions (flutter/flutter#169166)

fixes #169218
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.