-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
[macOS][platform_view] Rotating PlatformView produces unexpected results and causes crashes #124490
Comments
The crash is reproducible using the code sample & steps provided above. Moving the rotation slider also distorts the platform-view None of the transforms are applied on stable. flutter doctor -v
|
This seems to be a case of UIKit not being able to handle the case where the contents scale that is NAN ( |
cc @cbracken For macOS triage. |
Thanks - taking a look. Heads up @0xZOne that platform views are not yet officially supported on macOS. We're still working on a few things like trackpad gestures, and on the framework side -- the UiKit classes work by chance, rather than by design. That said, keep filing bugs - the more of these get uncovered before we announce support, the better :) |
@cbracken , Any timeline on when Platformview will become stable ? , So that we can adopt it in production |
This refactors `[FlutterMutatorView applyLayer:]` to split out orthogonal behaviour into smaller functions for better readability/maintainability. Extracts: * General transform composition to CATransformFromMutations * Opacity handling * MasterClip computation * RoundedRectClip computation This change is a cleanup change for readability and makes no semantic changes to how mutator views are applied. Existing unit tests in [FlutterMutatorViewTest.mm](https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterMutatorViewTest.mm) are expected to pass without changes. This is refactoring prior to applying a fix for rotation handling. Issue: flutter/flutter#124490 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Extracts `updatePathClipViewsWithPaths:origin:` which updates the stack of AppKit clip views hosting the platform view. This change is a cleanup change for readability and makes no semantic changes to how mutator views are applied. Existing unit tests in [FlutterMutatorViewTest.mm](https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterMutatorViewTest.mm) are expected to pass without changes. This is refactoring prior to applying a fix for rotation handling. Issue: flutter/flutter#124490
Extracts `updatePathClipViewsWithPaths:origin:` which updates the stack of AppKit clip views hosting the platform view. This change is a cleanup change for readability and makes no semantic changes to how mutator views are applied. Existing unit tests in [FlutterMutatorViewTest.mm](https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterMutatorViewTest.mm) are expected to pass without changes. This is refactoring prior to applying a fix for rotation handling. Issue: flutter/flutter#124490
@VarthanV For when an issue might be fixed, see: https://github.com/flutter/flutter/wiki/Issue-hygiene#when-will-my-bug-be-fixed We're actively working on PlatformViews for macOS right now, which will be followed by Windows. |
Extracts `updatePathClipViewsWithPaths:origin:` which updates the stack of AppKit clip views hosting the platform view. This change is a cleanup change for readability and makes no semantic changes to how mutator views are applied. Existing unit tests in [FlutterMutatorViewTest.mm](https://github.com/flutter/engine/blob/main/shell/platform/darwin/macos/framework/Source/FlutterMutatorViewTest.mm) are expected to pass without changes. This is refactoring prior to applying a fix for rotation handling. Issue: flutter/flutter#124490 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This extracts an extra method from `[FlutterMutatorView applyFlutterLayer:]` to perform the final PlatformViewContainer and PlatformView re-nesting in the view stack, then apply transforms, and finally apply the outer axis-aligned master clip rect around the whole thing. This is a refactoring for readability (primarily clearer parameterisation) and applies no semantic changes to the code. Issue: flutter/flutter#124490
This extracts an extra method from `[FlutterMutatorView applyFlutterLayer:]` to perform the final PlatformViewContainer and PlatformView re-nesting in the view stack, then apply transforms, and finally apply the outer axis-aligned master clip rect around the whole thing. This is a refactoring for readability (primarily clearer parameterisation) and applies no semantic changes to the code. This is the last in a series of refactoring applied to this method. Issue: flutter/flutter#124490 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
I do remember testing rotation when working on the mutator view, but there are probably edge cases that I missed. I'll give this a go. |
I have a fix for this here: https://github.com/knopp/engine/commits/macos_fix_platform_view_rotation |
I've actually got a stack of patches I'm in the middle of sharding out to refactor and land the fix, but didn't want to send it in one mega-patch in order to keep things manageable for reviewers. There are a couple more small refactor patches and then should be set. I'll have a look at your patch in case there are substantial differences. I've got a test. |
The fix for this is quite straightforward:
|
For consistency with Flutter (and all other platforms), Flutter views in the macOS embedder set `isFlipped` to ensure a co-ordinate system with the origin in the top-left, with y co-ordinates increasing towards the bottom edge of the view. Previously, we were using a stock NSView as the container, which uses a bottom-left origin by default. Instead we extract the PlatformView container view as its own class with `isFlipped` true. This doesn't correct the issue of the view anchorpoint/position but does correct rotation direction. This also applies the transform back to origin prior to other transforms when adjusting the platformview position rather than after. Issue: flutter/flutter#124490
For consistency with Flutter (and all other platforms), Flutter views in the macOS embedder set `isFlipped` to ensure a co-ordinate system with the origin in the top-left, with y co-ordinates increasing towards the bottom edge of the view. Previously, we were using a stock NSView as the container, which uses a bottom-left origin by default. Instead we extract the PlatformView container view as its own class with `isFlipped` true. This doesn't correct the issue of the view anchorpoint/position but does correct rotation direction. This also applies the transform back to origin prior to other transforms when adjusting the platformview position rather than after. Issue: flutter/flutter#124490
For consistency with Flutter (and all other platforms), Flutter views in the macOS embedder set `isFlipped` to ensure a co-ordinate system with the origin in the top-left, with y co-ordinates increasing towards the bottom edge of the view. Previously, we were using a stock NSView as the container, which uses a bottom-left origin by default. Instead we extract the PlatformView container view as its own class with `isFlipped` true. This doesn't correct the issue of the view anchorpoint/position but does correct rotation direction. This also applies the transform back to origin prior to other transforms when adjusting the platformview position rather than after. Issue: flutter/flutter#124490 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Fixed via flutter/engine#42523 |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
git clone git@github.com:0xZOne/platform_view_macos_example.git
flutter run -d macos
Crash Logs
flutter doctor -v
The text was updated successfully, but these errors were encountered: