flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.18k stars 27.49k forks source link

[android] path clipping not implemented for HC mode. #85933

Open neoyxm opened 3 years ago

neoyxm commented 3 years ago

Hi ,

These days, our project wanna use ClipOval to clip a Native view(Hybrid composition) on Android, but it doesn't work.

Meanwhile, the clip can work on AndroidView Virtual Display mode.

I posted the sample code to github to demstrate this issue.

Dart side: main.dart: https://github.com/neoyxm/neoMP/blob/master/main.dart

Native side to create the native view: MainActivity.java: https://github.com/neoyxm/neoMP/blob/master/MainActivity.java NativeView.java: https://github.com/neoyxm/neoMP/blob/master/NativeView.java NativeViewFactory.java: https://github.com/neoyxm/neoMP/blob/master/NativeViewFactory.java

Steps to Reproduce

  1. Run this sample ,and you will see the ClipOval doesn't work at all.
  2. If swithc to VirtualDisplay mode by marking the line 54 and unmarking line 55 in main.dart , the ClipOval works.

Expected results: https://github.com/neoyxm/neoMP/blob/master/Screenshot_20210706-095549.png

Actual results: https://github.com/neoyxm/neoMP/blob/master/Screenshot_20210706-101942.png

flutter doctor -v ```console [✓] Flutter (Channel stable, 2.2.2, on Mac OS X 10.15.7 19H1030 darwin-x64, locale zh-Hans-CN) • Flutter version 2.2.2 at /opt/flutter • Framework revision d79295af24 (3 weeks ago), 2021-06-11 08:56:01 -0700 • Engine revision 91c9fc8fe0 • Dart version 2.13.3 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/yangxm/Library/Android/sdk/ • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/yangxm/Library/Android/sdk/ • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264) ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.4, Build version 12D4e • CocoaPods version 1.10.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264) [✓] VS Code (version 1.57.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.24.0 [✓] Connected device (3 available) • LIO AL00 (mobile) • 7HX5T19929014779 • android-arm64 • Android 10 (API 29) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.7 19H1030 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114 ! Doctor found issues in 1 category. ```
TahaTesser commented 3 years ago

Hi @neoyxm Thanks for filing the issue, I have created the project from your code, Indeed ClipOval doesn't work but ClipRRect works fine

Here is the preview ClipRRect ClipOval

The easier way to confirm this is a hybrid composition and not a platform view issue is by using the official webview_example example

Uncomment or comment hybrid-composition, compare the results

Without hybrid composition With hybrid composition
stable master

Check flutter doctor -v outputs for each channel below

flutter doctor -v ```console [✓] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.22000.51], locale en-US) • Flutter version 2.2.3 at C:\Users\Taha\Code\flutter_stable • Framework revision f4abaa0735 (5 days ago), 2021-07-01 12:46:11 -0700 • Engine revision 241c87ad80 • Dart version 2.13.4 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Taha\Code\SDK • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = C:\Users\Taha\Code\SDK • Java binary at: C:\Users\Taha\Code\android-studio\jre\bin\java.exe • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) • All Android licenses accepted. [✓] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.10.3) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.10.31424.327 • Windows 10 SDK version 10.0.19041.0 [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions). [✓] VS Code (version 1.57.1) • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.24.0 [✓] Connected device (4 available) • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.51] • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.124 • Edge (web) • edge • web-javascript • Microsoft Edge 91.0.864.64 ! Doctor found issues in 1 category. ``` ```console [✓] Flutter (Channel master, 2.4.0-1.0.pre.84, on Microsoft Windows [Version 10.0.22000.51], locale en-US) • Flutter version 2.4.0-1.0.pre.84 at C:\Users\Taha\Code\flutter_master • Upstream repository https://github.com/flutter/flutter.git • Framework revision 691fa19dd7 (9 hours ago), 2021-07-06 02:06:04 -0400 • Engine revision c1ce39ecb7 • Dart version 2.14.0 (build 2.14.0-281.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Taha\Code\SDK • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = C:\Users\Taha\Code\SDK • Java binary at: C:\Users\Taha\Code\android-studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) • All Android licenses accepted. [✓] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.10.3) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.10.31424.327 • Windows 10 SDK version 10.0.19041.0 [✓] Android Studio (version 4.2.0) • Android Studio at C:\Users\Taha\Code\android-studio • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) [✓] VS Code (version 1.57.1) • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.24.0 [✓] Connected device (5 available) • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.51] • Windows (UWP) (desktop) • winuwp • windows-uwp-x64 • • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.124 • Edge (web) • edge • web-javascript • Microsoft Edge 91.0.864.64 • No issues found! ```

✅ : No Issue ❌: Issue reproduced

neoyxm commented 3 years ago

@TahaTesser Thanks for confirming this issue.

chinmaygarde commented 3 years ago

cc @blasten Is this a case of the mutator stack entry for ClipRRect not being implemented on the Android backend?

blasten commented 3 years ago

Right. This isn't implemented yet