-
Notifications
You must be signed in to change notification settings - Fork 6k
implemented GetMainContext() for opengl #23634
Conversation
0a97981
to
1dbb704
Compare
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@xster @iskakaushik friendly ping |
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.
Doh sorry missed this. LGTM. Could any of this be tested?
The new functionality would be covered under an existing test but since we don't run that test on OpenGL with the simulator it won't get exercised. As for the refactoring of the setup for OpenGL there are golden image tests that run on opengl devices as far as I know. I'll give unit tests directly on the opengl classes another look later today. |
50dcf08
to
3cad490
Compare
cleaned up and that the class behaves consistently
3cad490
to
079b09e
Compare
@@ -20,6 +20,8 @@ namespace flutter { | |||
|
|||
class GPUSurfaceGL : public Surface { | |||
public: | |||
static sk_sp<GrDirectContext> MakeGLContext(GPUSurfaceGLDelegate* delegate); |
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.
If possible, can we add some consistency between the metal version and this one? In metal, the IOSContextMetal just decides to make a GrDirectContext the way it wants without asking anyone. Here, it seems like the IOSSurfaceGL asks the GPUSurfaceGL to make one, then pushes it into IOSContextGL which then owns it.
IOSContextGL::~IOSContextGL() = default; | ||
IOSContextGL::~IOSContextGL() { | ||
if (main_context_) { | ||
main_context_->releaseResourcesAndAbandonContext(); |
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 know if it's possible. The various GPUSurfaceGL still has this shared pointer right? Could there be any risks?
sk_sp<GrDirectContext> context = gl_context->GetMainContext(); | ||
if (!context) { | ||
context = GPUSurfaceGL::MakeGLContext(this); | ||
gl_context->SetMainContext(context); |
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.
Ditto here. Seems like we have 2 timing characteristics. The metal case just makes this GrDirectContext way earlier when creating the shell's on_create_platform_view, whereas this makes it way later in FlutterViewController's viewWillAppear. There could be minutes in between if the engine was prewarmed.
I'm a bit worried that there might be side-effects involving platform views or memory etc that are hard to reproduce due to the rendering API differences.
It doesn't have to be in this PR, but I suppose this way works better memory wise. Can we make metal work this way too?
Though on the flip side, this likely shifts more of the latency away from the engine prewarming into the critical path for showing the first frame.
* 5b2defd Roll Fuchsia Mac SDK from MrtHftV0U... to 7nZajqutF... (flutter/engine#23827) * c8ffb20 Roll Skia from 87a055b02027 to e0d023562bd9 (1 revision) (flutter/engine#23829) * 296902b implemented GetMainContext() for opengl (flutter/engine#23634) * 5cf3eae Roll Skia from e0d023562bd9 to 982127b7d57d (4 revisions) (flutter/engine#23831) * fd9a079 [iOS] Fixes DisplayLinkManager leaks (flutter/engine#22194) * b241537 Roll Fuchsia Linux Toolchain from git_revision:2c0536b76b35fa592ac7b4a0e4bb176eaf55af75 to IJxh_9dNS... (flutter/engine#23832) * 5c2003f Roll Skia from 982127b7d57d to 6de1e52d0b12 (1 revision) (flutter/engine#23834) * 5b9cd44 Automatically download Noto fonts as backup fonts in CanvasKit mode (flutter/engine#23728) * 70a6824 Roll Dart SDK from 5e24a66b1bb8 to 704928da5702 (2 revisions) (flutter/engine#23838) * b0c46d8 Roll Skia from 6de1e52d0b12 to 8a37fb2c605b (5 revisions) (flutter/engine#23836) * d4132ea Use references when iterating over SkParagraph text boxes (flutter/engine#23837) * 87960d8 Fix typo in embedder unit tests (flutter/engine#23783) * 7f66714 iOS deeplink sends "path + query" instead of just path (flutter/engine#23562) * 1474d08 Roll Skia from 8a37fb2c605b to 37d16f135265 (4 revisions) (flutter/engine#23839) * 3da13fc Make android more lenient when it comes to out-of-order key event responses (flutter/engine#23604) * 9223073 Fix background crash when FlutterView going appear while app goes background (flutter/engine#23175) * 7c19824 Pass the filename directly to JNI for loading deferred component. (flutter/engine#23824) * 5dc2469 Reland path vol tracker (flutter/engine#23840) * e7e76f1 Roll Skia from 37d16f135265 to e89d8ea20b62 (2 revisions) (flutter/engine#23841) * 07f4861 Roll Dart SDK from 704928da5702 to 1db2d4d95562 (1 revision) (flutter/engine#23846) * 993ab78 Roll Skia from e89d8ea20b62 to c09761f57605 (1 revision) (flutter/engine#23843) * a4836a6 Call Dart plugin registrant if available (flutter/engine#23813) * 475a234 Roll Fuchsia Linux SDK from UGavhI1zv... to mODEe2CNk... (flutter/engine#23848) * b51da31 Roll Skia from c09761f57605 to 450f8565c7f3 (5 revisions) (flutter/engine#23851) * cb7106d Roll Skia from 450f8565c7f3 to 372791761157 (1 revision) (flutter/engine#23855) * 69980e5 Roll Fuchsia Mac SDK from 7nZajqutF... to tuJCioUf3... (flutter/engine#23857) * 20ff574 Roll Skia from 372791761157 to ce75036b3eaf (4 revisions) (flutter/engine#23858) * 0118b54 Implements accessibility bridge in common library (flutter/engine#23491) * ffc77f0 Search multiple paths when loading deferred component .so files. (flutter/engine#23849) * 71d264d Revert "implemented GetMainContext() for opengl (#23634)" (flutter/engine#23859) * fb48735 Roll Skia from ce75036b3eaf to cc6961b9ac5e (3 revisions) (flutter/engine#23860) * fdddf87 Roll Dart SDK from 1db2d4d95562 to 82b4c77fb17f (2 revisions) (flutter/engine#23861)
* 004d8ad Roll Skia from cc6961b9ac5e to 6a272434c2b2 (3 revisions) (flutter/engine#23864) * 7c2da3b reland of flutter/engine#23634 (flutter/engine#23865) * a4f02b7 Share Android surface GrDirectContext (flutter/engine#23798) * 31ef1dd Roll Skia from 6a272434c2b2 to bfc9be0f773f (2 revisions) (flutter/engine#23867) * 6dec57f Remove workarounds now that type promotion accounts for local boolean variables. (flutter/engine#23862) * a787229 Roll Skia from bfc9be0f773f to 3193ff271628 (5 revisions) (flutter/engine#23872) * a242dd8 [web] Fix shadows for arbitrary paths on PhysicalShape (flutter/engine#23830) * 05b4bec Started using Dart_CreateInGroup when using spawn on a release build (flutter/engine#23782)
…tter#23859) This reverts commit 296902b.
Description
For Metal, the IOSContext owns the skia context, for OpenGL it was the GPUSurface that owned the context. I've made the IOSContextGL behave like the IOSContextMetal which allowed us to percolate up a shared interface
GetMainContext()
. This effectively solves the sharing GPU context problem for OpenGL as well.Related Issues
fixes flutter/flutter#72021
#23539
Tests
I added the following tests:
No new functionality other than changing who has ownership of the skia context. Existing tests should cover it.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Reviewer Checklist
Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.