Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Issue 1682343002: AVDACodecImages keep a reference to the SurfaceTexture backing them (Closed)

Created:
4 years, 10 months ago by watk
Modified:
4 years, 8 months ago
CC:
chromium-reviews, posciak+watch_chromium.org, jam, mcasas+watch_chromium.org, feature-media-reviews_chromium.org, darin-cc_chromium.org, piman+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

AVDACodecImages keep a reference to the SurfaceTexture backing them Previously an AVDACodecImage became unbacked when the AndroidDeferredRenderingBackingStrategy was destructed. Now the images keep a reference to the SurfaceTexture so they remain drawable. This helps when the media pipeline is suspended, and AVDA is destructed, but video frames should still be visible. At the moment this is visible when foregrounding a background tab with a video element, but will help with making fullscreen transitions look better too. BUG=533630

Patch Set 1 #

Total comments: 8

Patch Set 2 : Comments #

Patch Set 3 : fix comment #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+86 lines, -64 lines) Patch
M content/common/gpu/media/android_deferred_rendering_backing_strategy.h View 1 chunk +3 lines, -3 lines 0 comments Download
M content/common/gpu/media/android_deferred_rendering_backing_strategy.cc View 1 5 chunks +24 lines, -18 lines 3 comments Download
M content/common/gpu/media/android_video_decode_accelerator.cc View 1 chunk +0 lines, -1 line 0 comments Download
M content/common/gpu/media/avda_codec_image.h View 3 chunks +5 lines, -2 lines 0 comments Download
M content/common/gpu/media/avda_codec_image.cc View 4 chunks +6 lines, -10 lines 0 comments Download
M content/common/gpu/media/avda_shared_state.h View 1 2 4 chunks +35 lines, -27 lines 0 comments Download
M content/common/gpu/media/avda_shared_state.cc View 1 3 chunks +13 lines, -3 lines 0 comments Download

Messages

Total messages: 15 (2 generated)
watk
Sorry about the unrelated clean up changes. I always get carried away.
4 years, 10 months ago (2016-02-10 02:02:20 UTC) #2
liberato (no reviews please)
this is a good idea. i'll go over this in more detail in the morning, ...
4 years, 10 months ago (2016-02-10 06:39:12 UTC) #3
liberato (no reviews please)
https://codereview.chromium.org/1682343002/diff/1/content/common/gpu/media/avda_shared_state.cc File content/common/gpu/media/avda_shared_state.cc (right): https://codereview.chromium.org/1682343002/diff/1/content/common/gpu/media/avda_shared_state.cc#newcode17 content/common/gpu/media/avda_shared_state.cc:17: AVDASharedState::~AVDASharedState() { i think that you have to maintain ...
4 years, 10 months ago (2016-02-10 21:05:14 UTC) #4
liberato (no reviews please)
https://codereview.chromium.org/1682343002/diff/1/content/common/gpu/media/avda_shared_state.cc File content/common/gpu/media/avda_shared_state.cc (right): https://codereview.chromium.org/1682343002/diff/1/content/common/gpu/media/avda_shared_state.cc#newcode17 content/common/gpu/media/avda_shared_state.cc:17: AVDASharedState::~AVDASharedState() { i think that you have to maintain ...
4 years, 10 months ago (2016-02-10 21:05:15 UTC) #5
watk
This stuff is getting more subtle with every change we make. I'm not sure how ...
4 years, 10 months ago (2016-02-11 00:26:51 UTC) #6
liberato (no reviews please)
hopefully i'm just wrong and there's no problem. -fl https://codereview.chromium.org/1682343002/diff/40001/content/common/gpu/media/android_deferred_rendering_backing_strategy.cc File content/common/gpu/media/android_deferred_rendering_backing_strategy.cc (right): https://codereview.chromium.org/1682343002/diff/40001/content/common/gpu/media/android_deferred_rendering_backing_strategy.cc#newcode27 content/common/gpu/media/android_deferred_rendering_backing_strategy.cc:27: ...
4 years, 10 months ago (2016-02-11 15:55:42 UTC) #7
watk
https://codereview.chromium.org/1682343002/diff/40001/content/common/gpu/media/android_deferred_rendering_backing_strategy.cc File content/common/gpu/media/android_deferred_rendering_backing_strategy.cc (right): https://codereview.chromium.org/1682343002/diff/40001/content/common/gpu/media/android_deferred_rendering_backing_strategy.cc#newcode27 content/common/gpu/media/android_deferred_rendering_backing_strategy.cc:27: glDeleteTextures(1, &service_id); On 2016/02/11 15:55:41, liberato wrote: > the ...
4 years, 10 months ago (2016-02-11 21:21:58 UTC) #8
watk
sandersd@: Any thoughts?
4 years, 10 months ago (2016-02-17 21:32:49 UTC) #10
watk
Frank, Dan and I took a look at this and it seems like maybe this ...
4 years, 8 months ago (2016-04-01 00:26:31 UTC) #11
liberato (no reviews please)
On 2016/04/01 00:26:31, watk wrote: > Frank, Dan and I took a look at this ...
4 years, 8 months ago (2016-04-01 05:58:08 UTC) #12
watk
On 2016/04/01 05:58:08, liberato wrote: > On 2016/04/01 00:26:31, watk wrote: > > Frank, Dan ...
4 years, 8 months ago (2016-04-01 20:29:10 UTC) #13
liberato (no reviews please)
On 2016/04/01 20:29:10, watk wrote: > On 2016/04/01 05:58:08, liberato wrote: > > On 2016/04/01 ...
4 years, 8 months ago (2016-04-01 21:49:07 UTC) #14
watk
4 years, 8 months ago (2016-04-01 22:09:26 UTC) #15
Message was sent while issue was closed.
On 2016/04/01 21:49:07, liberato wrote:
> On 2016/04/01 20:29:10, watk wrote:
> > On 2016/04/01 05:58:08, liberato wrote:
> > > On 2016/04/01 00:26:31, watk wrote:
> > > > Frank, Dan and I took a look at this and it seems like maybe this is
still
> > > > possible if we move the responsibility for calling
SetUnownedServiceId(0)
> to
> > > the
> > > > AVDACodecImage destructor. So if a different image is bound, the
> > > AVDACodecImage
> > > > destructor will reset the unowned id.
> > > > 
> > > > If the Texture is deleted, AVDACodecImage needs a way to detect that its
> > > Texture
> > > > was deleted to avoid calling SetUnownedServiceId, but other than that
> there
> > > seem
> > > > to be no issues.
> > > > 
> > > > Is this true? Or are there other subtleties that I've forgotten about?
It
> > > would
> > > > be really nice to get rid of the crash prone
> copySurfaceTextureToPictures..
> > > 
> > > i think it's slightly more complicated than that, but not too much.  one
> also
> > > needs something to own the SurfaceTexture and the gl texture that AVDA
> creates
> > > for it.
> > > 
> > > i think that you need something like this:
> > > 
> > > - shared state between AVDACodecImage that holds the ST and the service_id
> of
> > > the ST texture that AVDA created.
> > > -- this might be avda_shared_state, in fact.  not sure if it can be
re-used.
> 
> > > probably.
> > > - the shared state owns the ST texture.  in its destructor, it deletes it.
> > > - AVDACodecImage has a strong ref to the shared state
> > > -- keeps texture alive as long as any avdacodecimage / texture needs it.
> > > 
> > > to fix the 'texture was deleted' case:
> > > - a new call GLStreamTextureImage::NotifyDetachedFromTexture(Texture*)
> > > - Texture::SetLevelImage variants have to call NotifyDetachedFromTexture
if
> > the
> > > outgoing image is a stream texture
> > > -- this is trivial, since Texture already knows that it has a
> > > GLStreamTextureImage
> > > - codecimage::NotifyDetached... would clear the unowned texture id from
the
> > > outgoing texture.
> > > -- codecimage can also drop its strong ref to shared_state, if desired.
> > > -- codecimage is inactive at this point.  attaching it to other textures
> does
> > > nothing.
> > > - codecimage currently holds a raw ptr to the texture, which probably is
> bad. 
> > > Texture::Destroy should also call NotifyDetached, and NotifyDetached
should
> > > clear that raw ptr.
> > > -- shouldn't be possible to attach a codec image to another Texture, but
> it's
> > > something we ignore right now.  it could cause a crash if somebody manages
> to
> > do
> > > it.
> > > -- this makes it safe to attach a codec image elsewhere, so that we can
quit
> > > worrying about it.
> > > 
> > > i was thinking about this recently.  once we have this, it's almost
> > > straightforward to also include the codec itself in the shared state. 
then,
> > the
> > > textures show the correct frames, rather than the most recent front
buffer.
> > 
> > Nice. The first bit is implemented in this CL.
> > 
> > For the second bit, that sounds like it would work. Maybe we could avoid the
> > GLImage notification if AVDACI could look up the Texture it was originally
> > attached to via the client id (even if it's possible to attach the same
image
> to
> > multiple textures we only need to reset unowned id on the original). That
> would
> > rely on the lookup returning NULL if the texture is being deleted (i.e., if
> > we're running inside the Texture destructor), and I don't know if that's
true.
> > Crazy?
> 
> i'm not sure that will work.  the client id depends on the decoder. some other
> decoder (e.g., browser compositor) might have a reference to the Texture via a
> mailbox, whether the renderer still has a reference to it or not / decoder got
> destroyed / etc.

Hmm, good point. I don't know how the cross context sharing works. Dan suggested
using a mailbox to refer to the texture :).

> plus, the client id might get reused and point to some other texture.  while
> nothing too bad would happen, even if it was re-used as a PictureBuffer with
its
> own, different unowned texture, it's still a little weird.
>
> i think that an explicit notification that doesn't go through the decoder is
> going to be a lot more robust.

Powered by Google App Engine
This is Rietveld 408576698