Skip to content

Fix an ANR in HCPP rotation due to platform <-> raster thread deadlock - #190638

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
gmackall:fix-hcpp-rotation-anr
Aug 7, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:masterfrom
gmackall:fix-hcpp-rotation-anr

Conversation

@gmackall

@gmackall gmackall commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

…in place

Rotating an app with an HCPP platform view intermittently hangs the main
thread until an ANR. The traces show an AB-BA deadlock:

- Platform thread: SurfaceView.setFrame -> surfaceChanged ->
  nativeSurfaceChanged -> PlatformViewAndroid::NotifyChanged, which posts
  OnScreenSurfaceResize to the raster runner and blocks on a latch.
- Raster thread: Rasterizer::DrawToSurfaceUnsafe ->
  AndroidExternalViewEmbedder2::PrepareFlutterView -> DestroySurfaces,
  which posts to the platform runner and blocks on a latch.

The platform thread is inside ViewRootImpl.performTraversals, so it can
never drain the task the raster thread is waiting on, and vice versa.

This is HCPP-only because AndroidExternalViewEmbedder merges the raster
and platform threads whenever platform layers are present, so its
identical DestroySurfaces resolves inline via RunNowOrPostTask.
AndroidExternalViewEmbedder2 never merges, so the same code really
blocks cross-thread.

The singular overlay surface is persistent, so there is no reason to
destroy it on resize:

1. PrepareFlutterView no longer calls DestroySurfaces on frame resize.
2. SurfacePool::GetLayer resizes retained overlay surfaces in place via
   OnScreenSurfaceResize instead of destroying them. This is required,
   not incidental: GetLayer runs on the raster thread, and its existing
   destroy-on-resize branch would otherwise call destroyOverlaySurface2
   off the main thread. Nothing else resizes the swapchain either, since
   GPUSurfaceVulkanImpeller::AcquireFrame ignores the size it is handed.

This also stops leaking a SurfaceControl per rotation, since
PlatformViewsController2.destroyOverlaySurface releases the Surface but
never reparents or releases the SurfaceControl behind it.

The blocking CountDownLatch in SubmitFlutterView is the same hazard on
the first frame that has a platform view. Left for a follow-up.
Occupies the platform thread the way ViewRootImpl.performTraversals does
and asserts that a frame resize on the raster thread still completes,
rather than trying to reproduce both halves of the AB-BA race.

Releases the platform thread before asserting so that a regression fails
the test instead of hanging the suite.
@github-actions github-actions Bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Aug 6, 2026
@gmackall gmackall added the CICD Run CI/CD label Aug 6, 2026
@gmackall
gmackall marked this pull request as ready for review August 6, 2026 06:54
@gmackall
gmackall requested a review from a team as a code owner August 6, 2026 06:54
@gmackall
gmackall requested review from reidbaker and removed request for a team August 6, 2026 06:54

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the Android external view embedder to resize persistent overlay surfaces in place instead of destroying and recreating them when the frame size changes, preventing potential deadlocks between the raster and platform threads. It also adds corresponding unit and regression tests. The reviewer noted that when use_new_surface_methods_ is enabled, current_frame_size_ is not updated to requested_frame_size_ after resizing, which will cause redundant resize operations on every subsequent frame.

reidbaker
reidbaker previously approved these changes Aug 6, 2026

@reidbaker reidbaker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved but like other prs I would encourage you to get a review from someone better at c++.

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Readability review, mostly looks good to me. there's just a few notes:

  1. remove type deduction in noted places
  2. capture by std::move where noted

// The overlay surface is persistent, so resize it in place. Nothing else
// resizes the swapchain: |Surface::AcquireFrame| ignores the size it is
// handed.
for (const auto& layer : layers_) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

[](const SurfaceFrame&) { return true; }, frame_size2))));

auto surface_factory = std::make_shared<TestAndroidSurfaceFactory>(
[frame_size2, &surface_mock]() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd try capturing this by move surface_mock = std::move(surface_mock). That would better communicate that after this closure is created, the value shouldn't be relied upon. I think you'll have to make the closure mutable in order to move the capture from it.

[](const SurfaceFrame&) { return true; }, frame_size1))));

auto surface_factory =
std::make_shared<TestAndroidSurfaceFactory>([&surface_mock]() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit risky, capturing a raw pointer in an object that doesn't have a clear lifetime (since it is managed by a shared_ptr). You should again capture this with a move of the std::unique_ptr.

Comment on lines +1272 to +1279
fml::AutoResetWaitableEvent latch1;
fml::TaskRunner::RunNowOrPostTask(task_runners.GetRasterTaskRunner(), [&]() {
embedder->SubmitFlutterView(kImplicitViewId, nullptr, nullptr,
std::move(surface_frame1));
fml::TaskRunner::RunNowOrPostTask(task_runners.GetPlatformTaskRunner(),
[&latch1]() { latch1.Signal(); });
});
latch1.Wait();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This pattern is used a lot, I think you can simplify it with testing/post_task_sync.h

johnmccutchan
johnmccutchan previously approved these changes Aug 6, 2026
// The overlay surface is persistent, so resize it in place. Nothing else
// resizes the swapchain: |Surface::AcquireFrame| ignores the size it is
// handed.
for (const auto& layer : layers_) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

// the existing surfaces in the pool can't be recycled.
// The singular overlay surface is persistent, so it is resized in place by
// |SurfacePool::GetLayer| rather than destroyed and recreated here.
// Destroying it would block the raster thread on the platform thread, which

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find these retrospective comments helpful, they just make the codebase less clear for future readers. This code should have never destroyed the surface, it was a bug. We don't have to leave comments justifying bug fixes.

I would just leave:
// The singular overlay surface is persistent, so it is resized in place by
// |SurfacePool::GetLayer| rather than destroyed and recreated here.

And move the rest into the PR description as the motivation for the change. If people are curious they will use git blame and find the PR and understand why.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, deleted (gemini does this a lot and I find it annoying but failed to delete here before pushing, my bad)

MakeCopyable is needed because a lambda that move-captures a unique_ptr
isn't copy constructible, and TestSurfaceProducer is an std::function.

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readability lgtm!

@reidbaker reidbaker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restamp

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 7, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 7, 2026
Merged via the queue into flutter:master with commit 1857274 Aug 7, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 7, 2026
mboetger added a commit to mboetger/flutter that referenced this pull request Nov 9, 2026
…orm thread

The previous commit stopped `PrepareFlutterView` from destroying HC overlay
layers on a frame-size change and relied on `SurfacePool::GetLayer` to
replace them lazily. That mirrors flutter#190638, but HCPP keeps one persistent
overlay that it resizes in place, while HC overlays are `ImageReader`s sized
to the frame and can't be resized. Keeping them meant that after a resize
with no further overlay frames, the old overlays (three buffers each) stayed
allocated until teardown.

This restores HC's lifecycle, where overlays are destroyed when the frame size
changes, without the blocking hop:
- `SurfacePool::TakeLayers` removes the layers from the pool without calling
  into Java, so the next overlay is allocated at the new size.
- `AndroidExternalViewEmbedder::ReleaseOverlayLayers` releases their rendering
  surfaces on the thread that renders into them, then destroys the overlay
  views on the platform thread without waiting. When the threads are merged
  that call still runs inline, as before. Tasks run in the order they are
  posted, including across merged task queues, so the views are destroyed
  before a later frame can allocate new overlays.
- `DestroySurfaces` still waits, but only `Teardown` calls it, and the shell
  calls `Teardown` on the platform thread.

Tests:
- `DestroyOverlayLayersOnSizeChange` and
  `DoesNotDestroyOverlayLayersOnSizeChange` are restored from master. They now
  verify their expectations inside the test. Previously, the task that
  `PrepareFlutterView` posts kept the JNI mock alive past the end of the test,
  so their destroy expectations were only checked at exit.
- `ResizeDoesNotBlockRasterOnPlatformThread` now also checks that the old
  overlays are destroyed on the platform thread once it is free, that the next
  overlay frame allocates a new overlay without destroying again, and that
  teardown destroys it. It times out against master and fails against the
  previous commit.
- New `SurfacePool.TakeLayers` test.
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-flutter__flutter that referenced this pull request Nov 13, 2026
Fixes an Android Hybrid Composition (HC) platform <-> raster thread
deadlock during frame-size changes (the HC counterpart of
flutter#190638).

## Summary

- **Problem:** HC only merges the raster thread onto the platform thread
while platform views are in the scene. Once the last platform view
leaves and the merge lease expires, rasterization returns to `1.raster`,
while `SurfacePool` still holds the previously allocated HC
`OverlayLayer` instances (`ImageReader` surfaces sized to the old
viewport). On the next frame-size change (such as rotation),
`AndroidExternalViewEmbedder::PrepareFlutterView` called
`DestroySurfaces()`, posting a task to the platform thread and blocking
on a `WaitableEvent` latch:
1. **Mutual AB-BA Deadlock (ANR):** If the platform thread is
concurrently waiting on `1.raster` (`Shell::Screenshot` from
`FlutterRenderer.getBitmap()`, `PlatformViewAndroid::NotifyChanged` from
`surfaceChanged`, `NotifyDestroyed`, or `NotifySurfaceWindowChanged`),
neither thread can advance and the app ANRs.
2. **Unmerged Resize Stall & Wrong-Thread GPU Teardown:** Even when the
platform thread is not waiting on `1.raster`, `1.raster` stalls behind
main-thread Looper work and executes `DestroySwapchainKHR` /
`DestroySurfaceKHR` on the platform thread instead of `1.raster`.
- **Solution:**
- `SurfacePool::TakeLayers()` removes cached `OverlayLayer` entries from
the pool without calling into Java and sets `pending_java_destroy_ =
true` under `SurfacePool::mutex_` so subsequent HC frames allocate
overlays at the new frame size.
- `AndroidExternalViewEmbedder::ReleaseOverlayLayers()` clears those
`OverlayLayer` references directly on the rasterizing thread (releasing
the Impeller/Skia GPU surface and `VkSwapchainKHR` on `1.raster`) and
posts a non-blocking `SurfacePool::DestroyPendingLayers()` call to close
the stale Java `ImageReader`s on the platform thread via
`FlutterViewDestroyOverlaySurfaces()`.
- `SurfacePool::GetLayer()` and `SurfacePool::DestroyLayers()` also
flush `pending_java_destroy_` on the platform thread before creating new
overlays or returning from `Teardown()`.
- `AndroidExternalViewEmbedder::CreateSurfaceIfNeeded()` and
`SubmitFlutterView()` guard null `SurfaceFrame` returns if
`AcquireFrame()` fails on an overlay surface, skipping
`FlutterViewDisplayOverlaySurface()` and overlay submission instead of
dereferencing null.

> [!IMPORTANT]
> **Why `SurfacePool` flushes `pending_java_destroy_` in `GetLayer()`
and `DestroyLayers()`:** When a subsequent HC frame triggers
`RasterThreadMerger::MergeWithLease`, `MessageLoopTaskQueues` orders
tasks across the merged platform and raster queues by `(target_time,
order_)` assigned at `PostTask` time. A raster draw task queued before
`ReleaseOverlayLayers()` posts to the platform runner executes on the
platform thread *ahead* of that posted cleanup task. Flushing
`pending_java_destroy_` at the top of `SurfacePool::GetLayer()` destroys
the stale Java `ImageReader`s on `main` *before* allocating a fresh
overlay, turning the delayed cleanup task into a no-op and preventing
post-`Teardown()` JNI calls.

---

## Execution & Threading Flows (Before vs. After)

### 1. Unmerged Resize During Concurrent Platform <-> Raster Calls

#### Before (`master`): Synchronous Latch Causes AB-BA Deadlock &
Main-Thread GPU Teardown

```mermaid
sequenceDiagram
    participant P as Platform Thread (main)
    participant R as Raster Thread (1.raster)
    participant Pool as SurfacePool

    Note over P,Pool: HC platform view removed, merge lease expired (unmerged, stale OverlayLayer id=0 in Pool)
    P->>R: Resize viewport + BeginFrame submits resized LayerTree
    par Platform calls into Raster
        P->>R: Shell::Screenshot / NotifyChanged posts task + waits on raster latch
    and Raster calls into Platform
        R->>R: PrepareFlutterView detects frame_size_ != size
        R->>P: DestroySurfaces() posts task + waits on platform latch
    end
    Note over P,R: AB-BA DEADLOCK (both threads sleep forever -> ANR)
    Note over P,Pool: Even without Screenshot, 1.raster stalls until main is free, and main runs VkSwapchain teardown
```

<img width="5196" height="892" alt="image"
src="https://github.com/user-attachments/assets/34d22ddd-d950-4f6d-9ffb-35ac2bd70510"
/>


#### After (This PR): Non-Blocking Raster GPU Release + Async Java
`ImageReader` Cleanup

```mermaid
sequenceDiagram
    participant P as Platform Thread (main)
    participant R as Raster Thread (1.raster)
    participant Pool as SurfacePool

    Note over P,Pool: Unmerged mode with stale OverlayLayer id=0 in Pool
    P->>R: Resize viewport + BeginFrame submits resized LayerTree
    P->>R: Shell::Screenshot / NotifyChanged waits on raster latch
    R->>Pool: ReleaseOverlayLayers() -> TakeLayers() swaps layers_ & sets pending_java_destroy_ = true
    R->>R: layers.clear() drops GPU surface (VkSwapchain freed on 1.raster)
    R-)P: Post async task (no wait) -> DestroyPendingLayers()
    R->>R: RecreateSwapchain + finish Draw + service Screenshot
    R-->>P: Signal Screenshot latch (platform thread unblocks)
    P->>Pool: DestroyPendingLayers() flushes pending_java_destroy_ -> destroyOverlaySurfaces()
```

<img width="4858" height="1004" alt="image"
src="https://github.com/user-attachments/assets/54483fb7-b0d8-4453-83ad-54f561d88b5b"
/>


### 2. Dynamic Thread-Merge Queue Ordering & Teardown Barrier

On `master`, `PrepareFlutterView` blocked `1.raster` on a synchronous
latch before `PostPrerollAction` could reach `MergeWithLease()` (the
deadlock shown in Section 1). Making resize cleanup non-blocking
introduces a cross-queue ordering hazard unless `SurfacePool` tracks
pending Java overlay destruction:

#### Naive Async `PostTask` (Without `pending_java_destroy_`): Delayed
Cleanup Closes Live Overlay & Races `Teardown()`

```mermaid
sequenceDiagram
    participant R as Raster Queue (1.raster)
    participant Pool as SurfacePool (mutex_)
    participant P as Platform Queue (main)
    participant PVC as PlatformViewsController (Java)

    Note over R,P: Draw 1 runs on 1.raster while Draw 2 (with HC view) is already queued on Raster Queue (order=10)
    R->>Pool: Draw 1 PrepareFlutterView -> TakeLayers() empties layers_ (no pending flag)
    R-)P: Post async FlutterViewDestroyOverlaySurfaces() to Platform Queue (order=11)
    R->>P: Draw 1 PostPrerollAction -> MergeWithLease() merges queues + kSkipAndRetryFrame
    Note over Pool,PVC: Merged queue executes order=10 BEFORE order=11
    P->>Pool: Merged Draw 2 (order=10) GetLayer() sees empty layers_
    Pool->>PVC: createOverlaySurface() allocates live overlay (id=1) while stale id=0 stays open
    P->>PVC: Queued task (order=11) calls destroyOverlaySurfaces() -> closes BOTH stale id=0 AND live id=1!
    Note over Pool,PVC: If Teardown() runs before order=11 executes, HasLayers() == false returns early and order=11 calls JNI after Teardown()
```

<img width="5342" height="998" alt="image"
src="https://github.com/user-attachments/assets/774d51ec-d7f3-423e-be62-fe0d46ce00f0"
/>


#### After (This PR, `SurfacePool::pending_java_destroy_`): `GetLayer()`
& `DestroyLayers()` Flush Stale Overlays First

```mermaid
sequenceDiagram
    participant R as Raster Queue (1.raster)
    participant Pool as SurfacePool (mutex_)
    participant P as Platform Queue (main)
    participant PVC as PlatformViewsController (Java)

    Note over R,P: Draw 1 runs on 1.raster while Draw 2 (with HC view) is already queued on Raster Queue (order=10)
    R->>Pool: Draw 1 PrepareFlutterView -> TakeLayers() sets pending_java_destroy_ = true
    R-)P: Post async DestroyPendingLayers() to Platform Queue (order=11)
    R->>P: Draw 1 PostPrerollAction -> MergeWithLease() merges queues + kSkipAndRetryFrame
    Note over Pool,PVC: Merged queue executes order=10 BEFORE order=11
    P->>Pool: Merged Draw 2 (order=10) GetLayer() sees pending_java_destroy_ == true
    Pool->>PVC: Clears flag & calls destroyOverlaySurfaces() (closes id=0) BEFORE createOverlaySurface() (id=1)
    P->>Pool: Queued DestroyPendingLayers() (order=11) sees pending_java_destroy_ == false -> no-op (id=1 stays live)
    Note over Pool,PVC: If Teardown() runs before order=11 executes, DestroyLayers() flushes pending_java_destroy_ inline
```

<img width="5016" height="1002" alt="image"
src="https://github.com/user-attachments/assets/48e933cc-9b6c-4a38-93a1-a7bdfd1f2c80"
/>


---

## Perfetto Benchmark (Before vs. After on Physical Pixel 8, API 34)

Measured on a physical Google Pixel 8 (`shiba`, Android 14 / API 34,
`arm64-v8a`, Impeller Vulkan, debug-unopt local engine builds) across
**`n = 500` Before vs. `n = 500` After** unmerged HC resize cycles (`5`
interleaved ABBA batch pairs x `100` cycles per arm), plus **`n = 20`**
paired `deadlock_repro` trials and **`n = 5`** cold-start `dumpsys
meminfo` `Graphics` checks per arm. Each cycle renders an HC
`PlatformView` with an intersecting Flutter overlay, lets
`RasterThreadMerger`'s 10-frame lease expire back to `1.raster`, resizes
the `FlutterView`, and spins `main` for `55 ms` immediately after
`Animator::EndFrame` submits the resized `LayerTree` to `1.raster`:

| Metric (Pixel 8, API 34) | Before (`master`, `b718471b2c2`) | After
(PR `flutter#196255`, `62855a33e4c`) | Delta (`p50` / `mean`) |
| :--- | :---: | :---: | :---: |
| **Resize + `FlutterRenderer.getBitmap()` (`n = 20` trials/arm)** |
**`20 / 20` (`100%`) deadlocked / ANR** (`main` & `1.raster` stuck in
`S`) | **`0 / 20` (`0%`) deadlocked** (`getBitmap()` `p50` `252.0 ms`,
`p95` `279.5 ms`, `mean` `251.9 ± 21.2 ms`) | **Deadlock eliminated
(`20/20 -> 0/20`)** |
| **`1.raster` resize `GPURasterizer::Draw` under 55 ms `main` load (`n
= 500`/arm)** | `p50` **`81.76 ms`**, `p95` `94.60 ms` (`mean` `82.26 ±
6.77 ms`) | `p50` **`15.51 ms`**, `p95` `22.23 ms` (`mean` `16.38 ± 4.61
ms`) | **`-66.25 ms` (`-81.0%` `p50` / `-80.1%` `mean`)** |
| **`1.raster` sleep (`S`) inside resize `GPURasterizer::Draw` (`n =
500`/arm)** | `p50` **`60.80 ms`**, `p95` `64.80 ms` (`mean` `61.24 ±
1.97 ms`) on `DestroySurfaces()` latch | `p50` **`0.37 ms`**, `p95`
`1.39 ms` (`mean` `0.62 ± 2.30 ms`) (`0 ms` waiting on `main`) |
**`-60.43 ms` (`-99.4%` `p50` / `-99.0%` `mean`)** |
| **Main-thread overlay teardown slice sum (`n = 500`/arm)** | `p50`
**`1.46 ms`**, `p95` `2.38 ms` (`mean` `1.53 ± 0.48 ms`; full
`DestroyLayersLocked` span `p50` `3.31 ms`) | `p50` **`0.013 ms`**
(`13.2 us`), `p95` `0.021 ms` (`mean` `0.014 ± 0.006 ms`
`ImageReader.close()`) | **`-99.1%` slices (`-99.6%` span)** |
| **Vulkan swapchain + surface teardown thread (`n = 500`/arm)** |
**`main`:** `p50` **`1.37 ms`**, `p95` `2.25 ms` (`mean` `1.43 ± 0.47
ms`) | **`main`:** **`0.000 ms`** (`0/500`); **`1.raster`:** `p50` `1.15
ms`, `p95` `1.84 ms` (`mean` `1.23 ± 0.36 ms`) | **`-100%` Vulkan
teardown on `main`** |
| **`dumpsys meminfo` `Graphics` after unmerged resize (`n = 5`/arm)** |
`p50` `300,120 KB -> 151,284 KB` (`-148.8 MB`) | `p50` `300,120 KB ->
151,288 KB` (`-148.8 MB`) | **Full `~149 MB` reclaimed** |

---

## Tests

-
`AndroidExternalViewEmbedder.ResizeDoesNotBlockRasterOnPlatformThread`:
verifies unmerged frame-size changes do not block `1.raster` while the
platform thread is held, destroy stale overlays once the platform thread
runs, and allocate fresh overlays on subsequent HC frames.
-
`AndroidExternalViewEmbedder.MergedTaskAheadOfPostedResizeDestroyDestroysOldBeforeCreatingNew`:
reproduces the merged-queue `(target_time, order_)` interleaving and
verifies `SurfacePool::GetLayer()` destroys the stale overlay before
creating the new overlay and turns the delayed cleanup task into a
no-op.
-
`AndroidExternalViewEmbedder.TeardownDrainsPendingAsyncOverlayDestroy`:
verifies `Teardown()` synchronously flushes `pending_java_destroy_` so
zero JNI calls fire after `Teardown()` returns.
-
`AndroidExternalViewEmbedder.NullOverlaySurfaceFrameSkipsDisplayAndSubmit`:
verifies null overlay `SurfaceFrame` returns skip
`FlutterViewDisplayOverlaySurface()` and overlay `Submit()` while still
submitting the root frame.
- `AndroidExternalViewEmbedder.DestroyOverlayLayersOnSizeChange` and
`DoesNotDestroyOverlayLayersOnSizeChange`: verify overlay layer
lifecycle across changed and unchanged frame sizes.
- `SurfacePool.TakeLayers`,
`GetLayerFlushesPendingDestroyOnceAcrossMultipleOverlaysInFrame`, and
`TakeLayersPreservesPendingDestroyAcrossResizeBackToOriginalSize`:
verify `TakeLayers()`, `DestroyPendingLayers()`, `DestroyLayers()`,
multi-overlay pending-destroy flushing, and `size1 -> size2 -> size1`
resize oscillation.

## 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].
- [ ] 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.

<!-- 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/CONTRIBUTING.ai.md
[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
buptlink pushed a commit to AgoraIO-Extensions/Agora-Flutter-SDK that referenced this pull request Nov 17, 2026
…rfaceViewHdr

Flutter 3.50.0 adds several HCPP fixes on top of 3.44.5: rotation ANR
(flutter/flutter#190638), abort after the FlutterView detaches (#190612),
SurfaceControl transaction race (#192606) and use-after-free (#192969),
and the scroll clip lag (#189946).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants