Repository navigation
Commit f7b19ef
[engine] Release the Skia OpenGL resource context on shutdown (flutter#193592)
The Skia OpenGL embedder leaves its resource context current on the I/O
thread during shutdown. EGL defers destruction while a context remains
current, which can retain native graphics resources after engine
destruction.
Implement `EmbedderSurfaceGLSkia::ReleaseResourceContext` through the
existing embedder cleanup callback. The shell already invokes this hook
on the I/O thread after releasing the last IO manager. The GLES Impeller
surface already implements analogous cleanup.
Compatibility: for Skia GL embedders that provide
`make_resource_current`, this adds a `clear_current` call on the I/O
thread when the last I/O manager is released during shutdown, so
third-party callbacks that assume raster-thread-only execution need
review; `embedder.h` currently gives `clear_current` no thread contract.
Add `ShutdownReleasesOpenGLResourceContextOnItsThread`. It wraps the
fixture's real graphics callbacks, records the successful resource
binding's thread, and verifies that synchronous shutdown clears the
context on that thread. The change does not add a public API or alter
the embedder ABI.
Fixes flutter#193591.
Related:
[flutter#138893](flutter#138893)
identified the same EGL thread-binding mechanism on [December 12,
2023](flutter#138893 (comment)).
The reporter closed the issue on July 18, 2024, and it was locked on
August 1, 2024; no fixing PR is linked there. The linked focused issue
provides a standalone native reproduction of the missing Skia
resource-context release at `3829a944235cd8e25142d72302dc89db4cd16934`.
### Validation
Windows x64, `host_debug_unopt` (`--unoptimized --no-lto`), source
`3829a944235cd8e25142d72302dc89db4cd16934`:
- New regression with unchanged production code: failed both expected
release assertions (exit 1).
- With the two Skia production changes: the same regression passed (exit
0).
- Full `embedder_unittests`: 180 passed, 8 skipped, 1 pre-existing
disabled test; no failures (exit 0).
- Shutdown regression repeated 100 times: all passed (exit 0).
- Changed-line clang-format and `git diff --check`: passed.
The eight skips are five AOT-only checks in this JIT build and three
golden checks restricted to Linux. No test was disabled or skip
condition changed by this patch. Other platforms remain for upstream CI.
A C++ lifecycle comment documents the cleanup. No website documentation
update or Dart data-driven fix is included. Public API signatures and
ABI layouts are unchanged; third-party callback thread assumptions are
called out for compatibility review. The CLA is verified by the passing
`cla/google` check.
Earlier downstream evidence, on Flutter
`4cf24164269a5ebf0c16a028a00727d0e77bbb05`: stock Windows Skia reached
1,121,796,096 private bytes after 200 window cycles; the repaired build
settled at 243,449,856 bytes after 1,000 cycles. These are measurements
from that pinned engine, not benchmarks of the upstream revision tested
here. The linked issue contains the standalone native reproduction.
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
---------
Co-authored-by: gaaclarke <[email protected]>
Co-authored-by: Mairramer <[email protected]>1 parent 03f1d60 commit f7b19ef
3 files changed
Lines changed: 77 additions & 0 deletions
File tree
- engine/src/flutter/shell/platform/embedder
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
128 | 141 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
61 | 122 | | |
62 | 123 | | |
63 | 124 | | |
| |||
0 commit comments