Closed Bug 993598 Opened 10 years ago Closed 10 years ago

POST of MediaRecorder Blob drops first byte with long video slices

Categories

(Core :: Audio/Video: Recording, defect)

31 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: andreasg123, Assigned: bechen)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 2 obsolete files)

Attached file Test case
When recording video with MediaRecorder and uploading the Blob with xhr POST, the first byte is dropped for long video slices (2 seconds works correctly, 20 seconds does not).  In the sequence 1a 45 df a3, 1a is dropped.  The missing byte is included in byte count reported in the content-length header of the request.  I verified this by running WireShark on the HTTP traffic.

When calling FileReader.readAsArrayBuffer on the Blob and uploading the ArrayBuffer instead, the missing byte is included.

The video camera is a Logitech HD Pro Webcam C920 in case that makes a difference.
Component: General → Video/Audio: Recording
Product: Firefox → Core
Hi Benjamen, 
Could you help to check this problem?
We can reproduce the bug now include the 2s/20s blobs have different behaviors.

Vincent:
Should we move the bug to Necko?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(vchang)
Update status:
There is a data byte threshold in EncodedBufferCache.
If the data size accumulated over the threshold, we will create nsDOMTemporaryFileBlob, otherwise we create a nsDOMMemoryFile. 
I think that causes different behaviours for 2s and 20s blobs.

About the missing 1 byte, now we suspect the macro |NS_InputStreamIsBuffered| somehow it will read 1 byte of the blob.
http://dxr.mozilla.org/mozilla-central/source/content/base/src/nsXMLHttpRequest.cpp?from=nsxmlhttprequest.cpp#2732
Flags: needinfo?(vchang)
|nsDOMMemoryFile::GetInternalStream| retruns a seekable stream.

|nsDOMTemporaryFileBlob::GetInternalStream| returns a non-seekable stream.

Now I suspect the |nsTemporaryFileInputStream| does not implement nsISeekableStream.
OK, thanks, please help to fix it. :)
Blocks: 1008797
Attached patch bug-993598.patch (obsolete) — Splinter Review
Attachment #8420806 - Flags: feedback?(rlin)
Comment on attachment 8420806 [details] [diff] [review]
bug-993598.patch

Review of attachment 8420806 [details] [diff] [review]:
-----------------------------------------------------------------

Could we have a test case for recording more than 20s without passing timeslice?

::: netwerk/base/src/nsTemporaryFileInputStream.cpp
@@ +73,5 @@
>      uint32_t write_result = 0;
>      nsresult rv = writer(this, closure, buf,
>                           count - remainBufCount, bufCount, &write_result);
>      remainBufCount -= bufCount;
> +    if (NS_FAILED(rv)) {

You can use NS_ENSURE_SUCCESS(res, ret)
Attachment #8420806 - Flags: feedback?(rlin) → feedback+
(In reply to Randy Lin [:rlin] from comment #9)
> Comment on attachment 8420806 [details] [diff] [review]
> bug-993598.patch
> 
> Review of attachment 8420806 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Could we have a test case for recording more than 20s without passing
> timeslice?
Yes, bug 1008797 will do it. We may add more network tests there.
Attached patch bug-993598.patch (obsolete) — Splinter Review
Attachment #8420806 - Attachment is obsolete: true
Attachment #8420845 - Flags: review?(roc)
Attached patch bug-993598.patchSplinter Review
r=roc
try server: https://tbpl.mozilla.org/?tree=Try&rev=558497feb80c
Attachment #8420845 - Attachment is obsolete: true
Attachment #8421555 - Flags: review+
Keywords: checkin-needed
Randy: 
Do we need to uplift the patch to 1.2 1.3 1.4 etc...?
Flags: needinfo?(rlin)
1.4 may need this.
Flags: needinfo?(rlin)
As I'm getting all these email notifications, I had a look at the code being patched. That code assumes that PR_Read always reads as many bytes as asked as long as there isn't an error.  In my opinion, it would be better to write read_result bytes and advance mStartPos by that much.  If you also wanted to handle writer writing less than asked, you would need an inner loop.
https://hg.mozilla.org/mozilla-central/rev/cfb4a97f2fbf
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: