- Notifications
You must be signed in to change notification settings - Fork30k
[ios][pv]check UIScreen to be nil in platform view overlay setState call#166024
Conversation
| // There can be a race where UpdateViewState() is called when flutter_view or flutter_view's | ||
| // screen is nil when app is backgrounded. | ||
| FlutterView* flutterView = (FlutterView*)flutter_view; | ||
| if (!flutterView || !flutterView.screen || flutterView.screen.scale == 0.0f) { |
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 scale is actually 0.0 when it's backgrounded?
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 scale can be0, but just wanna be extra safe here.
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.
Yeah given this can result in a divide-by-zero, seems reasonable to check. Agreed it would seem like a definite UIKit bug to me if they ever returned a scale of 0, but checking for it seems fair.
You could consider a comment that we knowflutterView andflutterView.screen may be nil, but given scale is used in a scaling calculation division below, we're being paranoid.
cbracken left a comment
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.
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
jmagman commentedMar 27, 2025
Test failure in testLayerUpdateViewStateWithNilFlutterViewShouldNotCrash |
1eae5e7Uh oh!
There was an error while loading.Please reload this page.
…all (flutter#166024)A follow up toflutter#165525This checks against: 1. flutterView being nil2. flutterView's screen being nil3. flutterView's screen's scale being 0Again, since we can't repro, I am justing guessing here. *List which issues are fixed by this PR. You must list at least oneissue. An issue is not required if the PR fixes something trivial like atypo.*Internal only (See previous PR linked above)*If you had to change anything in the [flutter/tests] repo, include alink to the migration guide as per the [breaking change policy].*## Pre-launch Checklist- [x] I read the [Contributor Guide] and followed the process outlinedthere for submitting PRs.- [x] I read the [Tree Hygiene] wiki page, which explains myresponsibilities.- [x] I read and followed the [Flutter Style Guide], including [Featureswe expect every widget to implement].- [x] I signed the [CLA].- [x] I listed at least one issue that this PR fixes in the descriptionabove.- [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 DrivenFixes] where supported.- [ ] All existing and new tests are passing.If you need help, consider asking for advice on the #hackers-new channelon [Discord].<!-- Links -->[Contributor Guide]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview[Tree Hygiene]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md[test-exempt]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests[Flutter Style Guide]:https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md[Features we expect every widget to implement]:https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement[CLA]:https://cla.developers.google.com/[flutter/tests]:https://github.com/flutter/tests[breaking change policy]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes[Discord]:https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md[Data Driven Fixes]:https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…all (flutter#166024)A follow up toflutter#165525This checks against: 1. flutterView being nil2. flutterView's screen being nil3. flutterView's screen's scale being 0Again, since we can't repro, I am justing guessing here. *List which issues are fixed by this PR. You must list at least oneissue. An issue is not required if the PR fixes something trivial like atypo.*Internal only (See previous PR linked above)*If you had to change anything in the [flutter/tests] repo, include alink to the migration guide as per the [breaking change policy].*## Pre-launch Checklist- [x] I read the [Contributor Guide] and followed the process outlinedthere for submitting PRs.- [x] I read the [Tree Hygiene] wiki page, which explains myresponsibilities.- [x] I read and followed the [Flutter Style Guide], including [Featureswe expect every widget to implement].- [x] I signed the [CLA].- [x] I listed at least one issue that this PR fixes in the descriptionabove.- [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 DrivenFixes] where supported.- [ ] All existing and new tests are passing.If you need help, consider asking for advice on the #hackers-new channelon [Discord].<!-- Links -->[Contributor Guide]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview[Tree Hygiene]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md[test-exempt]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests[Flutter Style Guide]:https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md[Features we expect every widget to implement]:https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement[CLA]:https://cla.developers.google.com/[flutter/tests]:https://github.com/flutter/tests[breaking change policy]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes[Discord]:https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md[Data Driven Fixes]:https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…all (flutter#166024)A follow up toflutter#165525This checks against: 1. flutterView being nil2. flutterView's screen being nil3. flutterView's screen's scale being 0Again, since we can't repro, I am justing guessing here. *List which issues are fixed by this PR. You must list at least oneissue. An issue is not required if the PR fixes something trivial like atypo.*Internal only (See previous PR linked above)*If you had to change anything in the [flutter/tests] repo, include alink to the migration guide as per the [breaking change policy].*## Pre-launch Checklist- [x] I read the [Contributor Guide] and followed the process outlinedthere for submitting PRs.- [x] I read the [Tree Hygiene] wiki page, which explains myresponsibilities.- [x] I read and followed the [Flutter Style Guide], including [Featureswe expect every widget to implement].- [x] I signed the [CLA].- [x] I listed at least one issue that this PR fixes in the descriptionabove.- [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 DrivenFixes] where supported.- [ ] All existing and new tests are passing.If you need help, consider asking for advice on the #hackers-new channelon [Discord].<!-- Links -->[Contributor Guide]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview[Tree Hygiene]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md[test-exempt]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests[Flutter Style Guide]:https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md[Features we expect every widget to implement]:https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement[CLA]:https://cla.developers.google.com/[flutter/tests]:https://github.com/flutter/tests[breaking change policy]:https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes[Discord]:https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md[Data Driven Fixes]:https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

Uh oh!
There was an error while loading.Please reload this page.
A follow up to#165525
This checks against:
Again, since we can't repro, I am justing guessing here.
List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.
Internal only (See previous PR linked above)
If you had to change anything in theflutter/tests repo, include a link to the migration guide as per thebreaking change policy.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel onDiscord.