Closed Bug 951218 Opened 11 years ago Closed 11 years ago

Use RAII to unlock TextureHosts

Categories

(Core :: Graphics: Layers, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: nical, Assigned: nical)

References

Details

Attachments

(2 files, 3 obsolete files)

In some cases ImageHost may lock a texture hosts without unlocking it. Let's always use RAII to make sure that doesn't happen.
Attached patch Use RAII to unlock TextureHost (obsolete) (deleted) — Splinter Review
There was already a RAII helper in ContentHost.cpp, let's use move it to TextureHost.cpp and use it with all CompositableHosts.
Attachment #8348815 - Flags: review?(bjacob)
Attached patch Use RAII to unlock TextureHost (obsolete) (deleted) — Splinter Review
woops
Attachment #8348815 - Attachment is obsolete: true
Attachment #8348815 - Flags: review?(bjacob)
Attachment #8348829 - Flags: review?(bjacob)
Attached patch Use RAII to unlock TextureHost (deleted) — Splinter Review
some fixes
Attachment #8348829 - Attachment is obsolete: true
Attachment #8348829 - Flags: review?(bjacob)
Attachment #8349652 - Flags: review?(bjacob)
Attachment #8349652 - Flags: review?(bjacob) → review+
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Comment on attachment 8349652 [details] [diff] [review] Use RAII to unlock TextureHost :( This changed semantics and causes an assertion failure. >-class MOZ_STACK_CLASS AutoLockTextureHost >-{ >-public: >- AutoLockTextureHost(TextureHost* aHost) >- : mHost(aHost) >- { >- mLockSuccess = mHost ? mHost->Lock() : true; Note that the old code handled mHost == nullptr, by just saying success = true. >- if (!mTextureHost || >- !lock.IsValid() || >- !lockOnWhite.IsValid()) { >+ if (lock.Failed() || lockOnWhite.Failed()) { so this fails if mTextureHostOnWhite is nullptr, because the lock will have Failed(). I don't know if semantically we should treat a lock of a null texture as success, though.
Attachment #8349652 - Flags: review-
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch additional fixup (obsolete) (deleted) — Splinter Review
This fixes the failed assertion for me
Attachment #8350465 - Flags: review?(nical.bugzilla)
Attachment #8350465 - Flags: review?(bjacob)
Attachment #8350465 - Flags: review?(nical.bugzilla) → review+
Comment on attachment 8350465 [details] [diff] [review] additional fixup Review of attachment 8350465 [details] [diff] [review]: ----------------------------------------------------------------- ::: gfx/layers/composite/TextureHost.h @@ +786,4 @@ > AutoLockTextureHost(TextureHost* aTexture) > : mTexture(aTexture) > { > + mLocked = aTexture ? aTexture->Lock() : true; It's now too hard to see how the logic here deciding if we lock, matches the one in the destructor. At least, one problem is that mLocked is a lie if mTexture is null.
Attachment #8350465 - Flags: review?(bjacob) → review-
Doesn't matter, IMO. mLocked is an internal implementation detail. The external interface to the RAII helper only has a "Failed()" method.. which properly returns "didn't fail" if you try to lock a null texture. If you'd want it to match the destructor, it can be written as if (aTexture) { mLocked = aTexture->Lock(); } else { mLocked = true; // null textures are OK } But I don't think that buys much other than vertical space.
You can get r+ here either by renaming the internal mLocked variable to a name that reflects what it is, or by changing the logic --- your choice, but we shouldn't have variables, even internal, named mLocked, that can be true even if no texture was locked.
Attachment #8350465 - Attachment is obsolete: true
Attachment #8350782 - Flags: review?(bjacob)
Attachment #8350782 - Flags: review?(bjacob) → review+
Status: REOPENED → RESOLVED
Closed: 11 years ago11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: