Skip to content

Conversation

@matanlurey
Copy link
Contributor

Closes #160933.

The timing of this callback gives our users (and plugin authors) a chance to stop using the Surface before it becomes invalid, allowing us to fix #156488 - we no longer need to do shenanigans on storing and restoring state because ExoPlayer can now handle it out of the box; see #160933 (comment).

It's unfortunate we have to go through a bit of churn on the callback API, but realistically this is the feedback we were looking for when originally creating it - it just took longer than expected due to the long release cycle.

/cc @hasali19, @xxoo, @camsim99

@xxoo
Copy link

xxoo commented Dec 28, 2024

Thanks. I'm glad to see this change. Although I'm confused as to why it happened this time. Did something else change since #152839 was closed that made it more necessary?

@matanlurey
Copy link
Contributor Author

Another user filed a bug report with more details, so I understand the issue being presented now.

@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 6, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Jan 6, 2025
Merged via the queue into flutter:master with commit 351f274 Jan 6, 2025
179 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 6, 2025
@matanlurey matanlurey deleted the add-on-surface-cleanup branch January 6, 2025 19:26
@matanlurey matanlurey added the cp: stable cherry pick this pull request to stable release candidate branch label Jan 6, 2025
@flutteractionsbot
Copy link

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jan 7, 2025
…61252)

Follow-up to #160937
(#160933).

This more or less mirrors what we did already for `onSurfaceCreated` to
match `onSurfaceAvailable`.

With this approach, the master branch should immediately start seeing
better behavior in terms of being able to use the `onSurfaceDestroyed`
callback effectively (before the surface has been released). For
example, for a plugin that already uses `onSurfaceDestroyed`, [i.e
`camerax`](https://github.com/flutter/packages/blob/97ce56a68eea650dc784617b4eed7814cccedeb8/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/PreviewHostApiImpl.java):

```java
@OverRide
public void onSurfaceDestroyed() {
  // Invalidate the SurfaceRequest so that CameraX knows to to make a new request
  // for a surface.
  request.invalidate();
}
```

... the request is now invalidated _before_ the surface has been
destroyed, which is what (I believe) we wanted?

---

Folks that want to publish package updates that _definitely_ use the
correct timing will have to wait for the next stable.

/cc @hasali19 would be great to get your input here.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
srujzs pushed a commit to srujzs/flutter that referenced this pull request Jan 12, 2025
…utter#161252)

Follow-up to flutter#160937
(flutter#160933).

This more or less mirrors what we did already for `onSurfaceCreated` to
match `onSurfaceAvailable`.

With this approach, the master branch should immediately start seeing
better behavior in terms of being able to use the `onSurfaceDestroyed`
callback effectively (before the surface has been released). For
example, for a plugin that already uses `onSurfaceDestroyed`, [i.e
`camerax`](https://github.com/flutter/packages/blob/97ce56a68eea650dc784617b4eed7814cccedeb8/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/PreviewHostApiImpl.java):

```java
@OverRide
public void onSurfaceDestroyed() {
  // Invalidate the SurfaceRequest so that CameraX knows to to make a new request
  // for a surface.
  request.invalidate();
}
```

... the request is now invalidated _before_ the surface has been
destroyed, which is what (I believe) we wanted?

---

Folks that want to publish package updates that _definitely_ use the
correct timing will have to wait for the next stable.

/cc @hasali19 would be great to get your input here.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp: stable cherry pick this pull request to stable release candidate branch engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SurfaceProducer needs a "will destroy" signal, not a "did destroy" Simplify ImageReaderSurfaceProducer: Do not trim memory for external textures

4 participants