Closed Bug 819609 Opened 12 years ago Closed 12 years ago

Be defensive about videos we send to the HW decoder (video app crashes with low pmem (dequeueBuffer() needs proper error handling))

Categories

(Firefox OS Graveyard :: General, defect, P1)

ARM
Gonk (Firefox OS)

Tracking

(blocking-basecamp:+, firefox18 fixed, firefox19 fixed, firefox20 fixed, b2g18 fixed)

RESOLVED FIXED
blocking-basecamp +
Tracking Status
firefox18 --- fixed
firefox19 --- fixed
firefox20 --- fixed
b2g18 --- fixed

People

(Reporter: ikumar, Assigned: cjones)

References

Details

Attachments

(2 files)

STR:
1. Put few high resolution videos in /sdcard/Movies
2. Start video app
Video app crashes.
For a more consistent way to reproduce the issue: Reduce pmem size to 2MB or so and video app crashes with lower resolution(HVGA) videos as well.

Diagnosis:
Debugged it to find the problem in GrallocBufferActor::Create() doesn't do any error handling. This function gets eventually called from dequeueBuffer() in GonkNativeWindow.cpp.
When pmem is low then GraphicBuffer() fails and initCheck() returns an error but doesn't look like GrallocBufferActor::Create() is doing anything to propagate the error to dequeueBuffer().
See: https://github.com/mozilla/mozilla-central/blob/beta/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp#L169

As a result there is a bad dereference somewhere and dequeueBuffer() never returns. There are couple of other places in that file where we are creating GraphicBuffer but not doing any error handling.
blocking-basecamp: --- → ?
blocking-basecamp: ? → +
Priority: -- → P1
Oh, vomit.  The core code *is* actually propagating the errors correctly, although it's fairly confusing (my fault for that).

The problem is that the error-handling code in GonkNativeWindow::dequeueBuffer() is plain wrong.  We would crash any time allocation actually failed.  That code gave me a strong sense of deja vu, and the reason is that I already fixed that bug!  Just the patch wasn't uplifted correctly.  So let me fix that wagon and we can retest here.
Depends on: 809259
https://hg.mozilla.org/releases/mozilla-beta/rev/3f325888eb10

I'm confident enough that that's the fix to close this.  Please reopen if this doesn't do the trick.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Good catch Inder! Does this solve the problem in bug 804802 ?
Chris,
   I am still seeing the issue with this patch. The problem is it never returns back from the call to AllocSurfaceDescriptorGralloc() in dequeueBuffer(). The error check you added is after this function call which is never reached.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
over to cjones.  please unassign if you are not able to investigate (or reassign as appropriate).
Assignee: nobody → jones.chris.g
Summary: video app crashes with low pmem (dequeueBuffer() needs proper error handling) → Be defensive about videos we send to the HW decoder (video app crashes with low pmem (dequeueBuffer() needs proper error handling))
This sure doesn't feel like the right way to solve this bug but we have a priority request to stop the badness.  Followup work is already filed.
Attachment #690745 - Flags: review?(chris.double)
Just demonstrates the build properties that will need to be updated to enable the new code here.
Attachment #690747 - Flags: feedback?(mvines)
Attachment #690745 - Flags: review?(chris.double) → review+
It appears that the fallback google SW decoder is next to useless in practice.  This patch might end up causing videos that previously barely used to play to hit the SW decoder and not play.
Sadness.  There surely is another way for I believe there is good in this world.  

Do we shutdown the camera on home key these days?  If not then it's still consuming pmem and I bet we still can hit the bug.

Inder, can you show us the light?
(In reply to Michael Vines [:m1] from comment #10)
> Do we shutdown the camera on home key these days?  If not then it's still
> consuming pmem and I bet we still can hit the bug.
> 

We do.
Although even if we didn't, it would likely be easy to construct videos that passed this dumb check but still exhausted pmem.

I agree that there must be another way!
Whiteboard: [status-b2g18:fixed]
Whiteboard: [status-b2g18:fixed]
Attachment #690747 - Flags: feedback?(mvines) → feedback+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: