Skip to content

[Not plugin issue, Flutter Engine] Android PlatformView Display Mode Issues #152

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

Closed
note11g opened this issue Jan 5, 2024 · 5 comments
Closed

Comments

@note11g
Copy link
Owner

note11g commented Jan 5, 2024

Background

flutter_naver_map 플러그인은 더 나은 성능을 위해, Android 플랫폼에서 TextureView 대신, GLSurfaceView를 사용하여 렌더링합니다.
하지만, 이로 인해 플랫폼 뷰 위젯에 많은 이슈가 발생하고 있습니다. 이를 수집하고 정리하기 위해 해당 이슈를 생성합니다.

The flutter_naver_map plugin uses GLSurfaceView instead of TextureView for rendering on the Android platform, aiming for better performance.
However, many issues have been occurring at PlatformView Widget. This issue has been created to collect and organize them.

@note11g
Copy link
Owner Author

note11g commented Jan 12, 2024

본 코멘트는 Flutter 3.16~Flutter 3.18, flutter_naver_map 1.1.2 를 기준으로 서술되었습니다.

Flutter에는 Android PlatformView에서 사용할 수 있는 디스플레이 모드가 3가지 있습니다.

  1. Hybrid Composition (이하 HC)
  2. Texture Layer Hybrid Composition (이하 TLHC)
  3. Virtual Display (이하 VD)

그리고, 실제로 Flutter 엔진이 플러터 위젯들을 그리는 공간인 FlutterView는 두가지 렌더링 뷰를 지원합니다.

  1. SurfaceView (Default, 이하 SV)
  2. TextureView (이하 TV)

또한, NaverMap Android SDK 역시 두가지 렌더링 뷰를 지원합니다.

  1. GLSurfaceView (이하 GLSV)
  2. TextureView

여기에서는 해당 선택지를 어떻게 조합하고 구성하냐에 따라, 어떤 Trade-Off들이 존재하는지와 flutter_naver_map에서는 버전별로 어떻게 구현되어 있는지 서술합니다.


1. 성능

  • FlutterAndroidPlatformView : TLHC > HC > VD
  • AndroidRenderView : SV (or GLSV) > TV

따라서, flutter_naver_map에서는 MapRendering에 GLSV를 기본으로 사용하되 아래 서술할 호환성에 문제가 있는 기기들에서는 TV를 사용합니다.

Android Version Flutter Platform View Type Flutter Rendering View Naver Map Rendering View
14(API 34)~ Hybrid Composition SurfaceView GLSurfaceView
11~13(API 30~33) Hybrid Composition TextureView GLSurfaceView
6.0~10(API 23~29) Texture Layer Hybrid Composition SurfaceView TextureView

2. 호환성 (이슈)

[MapRenderView] GLSurfaceView

  • 앱이 백그라운드로 전환되었다가, 다시 돌아오면 Navigator Stack의 Z-Order를 무시하고, GLSurfaceView만 위로 나타납니다. 이때, GLSV와의 상호작용은 불가능합니다. (#56, flutter/#89558, Android 14부터는 재현되지 않습니다. Android 10~13에서는 Flutter Renering View를 TextureView로 바꾸면 해결할 수 있습니다.)

[Platform View] Hybrid Composition

  • Opacity가 적용되지 않습니다. (flutter/#93757, #68, flutter/#118498)
  • Navigtor Stack에 새로운 페이지가 push 되었을 때, Rerender 과정에서 PlatformView가 잠시 보여집니다.
    (#84, flutter/#113167)
  • Flutter 3.16부터 Android 6.0~10에서 GLSV + TLHC 사용시 PlatformView가 검정색으로 뜹니다. 지도와의 상호작용은 가능하며, 지도 내장 screenshot 기능 역시 잘 작동합니다. (#135)

[Platform View] Texture Layer Hybrid Composition

  • 앱이 백그라운드로 전환되었다가 다시 돌아오면, 빈화면으로 뜨거나, 플랫폼뷰와 상호작용할 수 없습니다. 혹은 ANR을 발생시킵니다.(flutter#98865, Android 11~12에서 재현됨)

@johnmccutchan
Copy link

Because of how SurfaceViews render in Android, Flutter will always have trouble supporting them completely and you should avoid using them in a Flutter app.

FWIW: Google Maps on Android uses TextureView (not just in Flutter but in general) and it has great performance.

@note11g
Copy link
Owner Author

note11g commented Feb 15, 2024

Need to check flutter 3.19's Update (TLHC, Impeller)

@note11g
Copy link
Owner Author

note11g commented Feb 16, 2024

flutter/flutter#98865 가 flutter 3.19에서 해결된 것으로 보입니다.
1.2.0부터는 TLHC모드를 기본으로 사용합니다. (동시에, min flutter version과 min dart 역시 업그레이드 됩니다)

60c16d5 관련 커밋입니다.

다음은 해결되는 Hybrid Composition 관련 이슈들입니다.

또한, flutter 3.19에서 TLHC와 함께 사용시, GLSurfaceView 문제 역시 해결되었습니다.
따라서, 이제 Android 11~13(API 30~33)에서 FlutterView를 TextureView로 사용하지 않습니다. 나머지는 현행 유지합니다.

8048352 관련 커밋입니다.

다음은 해결되는 GLSurfaceView 관련 이슈들입니다.

수정해주신 Flutter팀께 감사 말씀을 올립니다!
Thank you to the Flutter team for fixing the issues! @johnmccutchan

@note11g
Copy link
Owner Author

note11g commented Feb 16, 2024

해당 이슈에 관련된 이슈는 대부분 수정된 것으로 보입니다.
곧 1.2.0 버전이 업그레이드 되고 나면, 해당 이슈는 닫힙니다.
감사합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants