Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Replace deprecated [UIScreen mainScreen] in FlutterViewController.mm and FlutterViewControllerTest.mm #43690

Merged
merged 7 commits into from
Jul 24, 2023

Conversation

mossmana
Copy link
Contributor

@mossmana mossmana commented Jul 14, 2023

Issue: flutter/flutter#128260

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@mossmana mossmana changed the title renaming mainScreenIfViewLoaded to screenIfViewLoaded to better match… Replace deprecated [UIScreen mainScreen] in FlutterViewController.mm and FlutterViewControllerTest.mm Jul 14, 2023
@mossmana mossmana force-pushed the issue128260 branch 6 times, most recently from be2b56d to 4236cdd Compare July 18, 2023 20:27
@mossmana mossmana marked this pull request as ready for review July 18, 2023 21:00
Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks clean

@@ -1871,7 +1876,6 @@ - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences {
if (!windowScene) {
// When the view is not loaded, it does not make sense to access the interface
// orientation, bail.
FML_LOG(WARNING) << "Trying to access the window scene before the view is loaded.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intended change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log is a bit redundant, since the windowSceneIfViewLoaded function that is called in the line above already logs the message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, I guess there could be a case where the windowScene could be null for other reasons. Maybe rather than delete the line, I should log out the comment instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah even if both are logged, one is for window scene, and the other is for screen, so not exactly duplicate.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

viewFrame:(CGRect)viewFrame
convertedFrame:(CGRect)convertedFrame {
OCMStub([viewControllerMock mainScreenIfViewLoaded]).andReturn(UIScreen.mainScreen);
- (id)setupMockScreen {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: setUp
(We do have a lot of misuse of "setup" in our engine code. I think I can create a PR to clean them up)
cc @stuartmorgan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I wasn't even considering the appropriate verb vs. the noun usage when I modeled against existing functions. I'll go ahead and make the change for this test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or createMockScreen may be more accurate about what the function is doing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historically, in the context of a test (not just for iOS), I've usually seen setUp more than create. They can be considered synonyms so, I think I'll go with setUp.

@hellohuanlin
Copy link
Contributor

I went through the places you early return if view is not loaded - I think they are all safe to return, since they are all called after the view is loaded, e.g. scroll callbacks.

CC @cyanglaz to double check, especially for add-to-app scenario that I'm not familiar with

@hellohuanlin
Copy link
Contributor

Circling back from the triage meeting with chris and stuart - the add-to-app scenario should be fine. i think we are good to land this one.

@mossmana mossmana merged commit ff02fa7 into flutter:main Jul 24, 2023
@mossmana mossmana deleted the issue128260 branch July 24, 2023 20:29
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 24, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 24, 2023
…131221)

flutter/engine@a489c74...ff02fa7

2023-07-24 233583+mossmana@users.noreply.github.com Replace deprecated [UIScreen mainScreen] in FlutterViewController.mm and FlutterViewControllerTest.mm (flutter/engine#43690)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC bdero@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jul 31, 2023
…lutter#131221)

flutter/engine@a489c74...ff02fa7

2023-07-24 233583+mossmana@users.noreply.github.com Replace deprecated [UIScreen mainScreen] in FlutterViewController.mm and FlutterViewControllerTest.mm (flutter/engine#43690)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC bdero@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
vashworth pushed a commit to vashworth/flutter that referenced this pull request Aug 2, 2023
…lutter#131221)

flutter/engine@a489c74...ff02fa7

2023-07-24 233583+mossmana@users.noreply.github.com Replace deprecated [UIScreen mainScreen] in FlutterViewController.mm and FlutterViewControllerTest.mm (flutter/engine#43690)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC bdero@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace deprecated [UIScreen mainScreen] in FlutterViewController.mm and FlutterViewControllerTest.mm
3 participants