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

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Apr 11, 2023

Noticed this while working on flutter/flutter#124181

In Impeller right now, Android creates a context for each surface - but in Skia, Android creates one context and shares it across surfaces. For the multiple-engine scenario this matters. This also makes it possible for Android to provide the impeller::Context independently of surface creation.

Makes the impeller::Context available to the rasterizer ASAP, so
that even if it has not received a surface yet calls to `toImage`
and `toImageSync` can still produce a texture.
@dnfield dnfield marked this pull request as ready for review April 11, 2023 17:14
@dnfield
Copy link
Contributor Author

dnfield commented Apr 11, 2023

(Looking into the test failure)

@dnfield
Copy link
Contributor Author

dnfield commented Apr 11, 2023

I'm going to wire up an Impeller variant of test_surface_gl

@jason-simmons
Copy link
Member

I'm seeing errors at startup when I try to run a demo of multiple engines created from a FlutterEngineGroup with this PR:

E/flutter ( 9053): [ERROR:flutter/impeller/toolkit/egl/egl.cc(56)] EGL Error: Bad Access (12290) in ../../flutter/impeller/toolkit/egl/context.cc:55
E/flutter ( 9053): [ERROR:flutter/shell/platform/android/android_surface_gl_impeller.cc(24)] Could not make offscreen context current.
F/flutter ( 9053): [FATAL:flutter/shell/platform/android/platform_view_android.cc(124)] Check failed: android_surface_ && android_surface_->IsValid(). Could not create an OpenGL, Vulkan or Software surface to set up rendering.

@dnfield
Copy link
Contributor Author

dnfield commented Apr 11, 2023

I've updated the test to use the Metal backend. The GL backend has an additional complication, which I described in flutter/flutter#124635.

We should fix that separately IMHO.

@dnfield
Copy link
Contributor Author

dnfield commented Apr 11, 2023

I'm seeing errors at startup when I try to run a demo of multiple engines created from a FlutterEngineGroup with this PR:

E/flutter ( 9053): [ERROR:flutter/impeller/toolkit/egl/egl.cc(56)] EGL Error: Bad Access (12290) in ../../flutter/impeller/toolkit/egl/context.cc:55
E/flutter ( 9053): [ERROR:flutter/shell/platform/android/android_surface_gl_impeller.cc(24)] Could not make offscreen context current.
F/flutter ( 9053): [FATAL:flutter/shell/platform/android/platform_view_android.cc(124)] Check failed: android_surface_ && android_surface_->IsValid(). Could not create an OpenGL, Vulkan or Software surface to set up rendering.

d570bbb fixes that locally for me.

@dnfield
Copy link
Contributor Author

dnfield commented Apr 13, 2023

From triage: I'm going to make a smaller version of this patch that doesn't touch Android as much yet.

@dnfield dnfield changed the title [Impeller] Make toImageSync use the context instead of requiring a surface. [Impeller] [Android] Refactor the Android context/surface implementation to work more like Skia. Apr 14, 2023
@dnfield dnfield marked this pull request as ready for review April 14, 2023 03:12
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
@dnfield dnfield deleted the imp_img_sync branch May 12, 2023 16:15
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 12, 2023
zanderso pushed a commit to flutter/flutter that referenced this pull request May 12, 2023
…126714)

flutter/engine@c784d6d...502e1eb

2023-05-12 [email protected] [Impeller] starts
running vulkan golden image tests with swiftshader
(flutter/engine#41958)
2023-05-12 [email protected] [web] Fix crash on old versions of Chrome
(Intl.Segmenter missing) (flutter/engine#41986)
2023-05-12 [email protected] Move clang tidy v2 build to prod.
(flutter/engine#41985)
2023-05-12 [email protected] Reland "Move linux_license to engine
v2."" (flutter/engine#41983)
2023-05-12 [email protected] Roll Dart SDK from
6cd6e54f280d to 858f83d6d993 (2 revisions) (flutter/engine#41980)
2023-05-12 [email protected] Roll Skia from 0b929ada9cc6 to
539fb10d7cfb (2 revisions) (flutter/engine#41979)
2023-05-12 [email protected] Roll Fuchsia Mac SDK from
MjcKzcsqMDkuRKopu... to rO5qs4MpN6WfJcu64... (flutter/engine#41975)
2023-05-12 [email protected] Roll Dart SDK from
4028c7d8b87c to 6cd6e54f280d (1 revision) (flutter/engine#41974)
2023-05-12 [email protected] Roll Fuchsia Linux SDK from
lf8VcONMWlne4oa3H... to HMLNsG7w9sTDpW2Ge... (flutter/engine#41973)
2023-05-12 [email protected] Roll Skia from 208a07f71701 to
0b929ada9cc6 (2 revisions) (flutter/engine#41971)
2023-05-12 [email protected] [Impeller] [Android] Refactor the Android
context/surface implementation to work more like Skia.
(flutter/engine#41059)
2023-05-12 [email protected] Roll Skia from ccec5093ca38 to
208a07f71701 (1 revision) (flutter/engine#41970)
2023-05-12 [email protected] [Impeller] Dont synthesize fake
index buffer if none was provided to VBB (flutter/engine#41969)
2023-05-12 [email protected] [Impeller] Make index buffer optional
(flutter/engine#41962)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from lf8VcONMWlne to HMLNsG7w9sTD
  fuchsia/sdk/core/mac-amd64 from MjcKzcsqMDku to rO5qs4MpN6Wf

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 [email protected],[email protected],[email protected] 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
CaseyHillers pushed a commit to CaseyHillers/flutter that referenced this pull request May 24, 2023
…lutter#126714)

flutter/engine@c784d6d...502e1eb

2023-05-12 [email protected] [Impeller] starts
running vulkan golden image tests with swiftshader
(flutter/engine#41958)
2023-05-12 [email protected] [web] Fix crash on old versions of Chrome
(Intl.Segmenter missing) (flutter/engine#41986)
2023-05-12 [email protected] Move clang tidy v2 build to prod.
(flutter/engine#41985)
2023-05-12 [email protected] Reland "Move linux_license to engine
v2."" (flutter/engine#41983)
2023-05-12 [email protected] Roll Dart SDK from
6cd6e54f280d to 858f83d6d993 (2 revisions) (flutter/engine#41980)
2023-05-12 [email protected] Roll Skia from 0b929ada9cc6 to
539fb10d7cfb (2 revisions) (flutter/engine#41979)
2023-05-12 [email protected] Roll Fuchsia Mac SDK from
MjcKzcsqMDkuRKopu... to rO5qs4MpN6WfJcu64... (flutter/engine#41975)
2023-05-12 [email protected] Roll Dart SDK from
4028c7d8b87c to 6cd6e54f280d (1 revision) (flutter/engine#41974)
2023-05-12 [email protected] Roll Fuchsia Linux SDK from
lf8VcONMWlne4oa3H... to HMLNsG7w9sTDpW2Ge... (flutter/engine#41973)
2023-05-12 [email protected] Roll Skia from 208a07f71701 to
0b929ada9cc6 (2 revisions) (flutter/engine#41971)
2023-05-12 [email protected] [Impeller] [Android] Refactor the Android
context/surface implementation to work more like Skia.
(flutter/engine#41059)
2023-05-12 [email protected] Roll Skia from ccec5093ca38 to
208a07f71701 (1 revision) (flutter/engine#41970)
2023-05-12 [email protected] [Impeller] Dont synthesize fake
index buffer if none was provided to VBB (flutter/engine#41969)
2023-05-12 [email protected] [Impeller] Make index buffer optional
(flutter/engine#41962)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from lf8VcONMWlne to HMLNsG7w9sTD
  fuchsia/sdk/core/mac-amd64 from MjcKzcsqMDku to rO5qs4MpN6Wf

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 [email protected],[email protected],[email protected] 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
jason-simmons added a commit to jason-simmons/flutter_engine that referenced this pull request Jul 31, 2023
…and its swapchain

In flutter#41059 the Android context and
surface were changed to share one impeller::ContextVK across all
instances of AndroidSurfaceVulkanImpeller.  However, the ContextVK
holds a reference to the current swapchain.  If an app uses multiple
AndroidSurfaceVulkanImpeller instances (e.g. for platform views), then
one surface may overwrite the ContextVK's swapchain while another
surface is trying to render.

This patch allows each surface to get its own impeller::Context
instance holding a swapchain tied to that surface.  The per-surface
contexts will delegate most operations to the shared parent ContextVK.
jason-simmons added a commit to jason-simmons/flutter_engine that referenced this pull request Jul 31, 2023
…and its swapchain

In flutter#41059 the Android context and
surface were changed to share one impeller::ContextVK across all
instances of AndroidSurfaceVulkanImpeller.  However, the ContextVK
holds a reference to the current swapchain.  If an app uses multiple
AndroidSurfaceVulkanImpeller instances (e.g. for platform views), then
one surface may overwrite the ContextVK's swapchain while another
surface is trying to render.

This patch allows each surface to get its own impeller::Context
instance holding a swapchain tied to that surface.  The per-surface
contexts will delegate most operations to the shared parent ContextVK.
auto-submit bot pushed a commit that referenced this pull request Jul 31, 2023
…and its swapchain (#44171)

In #41059 the Android context and surface were changed to share one impeller::ContextVK across all instances of AndroidSurfaceVulkanImpeller.  However, the ContextVK holds a reference to the current swapchain.  If an app uses multiple AndroidSurfaceVulkanImpeller instances (e.g. for platform views), then one surface may overwrite the ContextVK's swapchain while another surface is trying to render.

This patch allows each surface to get its own impeller::Context instance holding a swapchain tied to that surface.  The per-surface contexts will delegate most operations to the shared parent ContextVK.
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
…and its swapchain (flutter#44171)

In flutter#41059 the Android context and surface were changed to share one impeller::ContextVK across all instances of AndroidSurfaceVulkanImpeller.  However, the ContextVK holds a reference to the current swapchain.  If an app uses multiple AndroidSurfaceVulkanImpeller instances (e.g. for platform views), then one surface may overwrite the ContextVK's swapchain while another surface is trying to render.

This patch allows each surface to get its own impeller::Context instance holding a swapchain tied to that surface.  The per-surface contexts will delegate most operations to the shared parent ContextVK.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller platform-android

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants