Improve performance of Stagefright internal http server




6 years ago
3 years ago


(Reporter: cajbir, Unassigned, Mentored)



Firefox Tracking Flags

(Not tracked)


(Whiteboard: [lang=c++])



6 years ago
The stagefright internal http server introduced in bug 860599 is not optimal for performance. It uses a blocking/threaded structure with unneeded copying of data. This should be improved as recommended by Honza Bambas un bug 860599 comment 34.


6 years ago
Whiteboard: [lang=c++][mentor=doublec]


6 years ago
Depends on: 860599

Comment 1

6 years ago
I would be happy to take a look if no one has fixed this yet.  Just let me know what files I'll need to look at and I'll get started.

Comment 2

6 years ago
That would be great! The existing http server code is in:


The server is instantiated in:


It is accessed from:

media/omx/OmxPlugin.cpp (OmxDecoder::Init)

The main code will bein the MediaResourceServer files.

Comment 3

6 years ago
Alright, I've taken a look at the bug you linked in your first comment.  I'm completely new to this codebase so I don't really know what a lot of these classes do yet.  From what I gathered from Honza's post, the current implementation is inefficient because of how many times it unnecessarily copies code.  It looks like he has identified the copy to a pipe here in the routine for opening an input stream (when OPEN_BLOCKING is passed as a parameter) as a copy that could be eliminated.  It looks to me like the code for opening an unbuffered input stream in the same function does avoid this copy because it doesn't use the pipe, however, wouldn't we run into concurrency issues with that approach or am I completely confused?  

I'm also quite confused about what this suggestion by Honza means: "You may implement nsIInputStream that wraps the MediaResource.  This way you can use stream copier (via WriteSegments to the socket output stream)."
nsIInputStream is an interface defined here: . It allows reading from some arbitrary source in a controlled, efficient way. There are various examples of classes that implement it, usually named nsSomethingStream:

Comment 5

6 years ago
Ok first of all sorry I disappeared for a few days, between classes, job interviews and a midterm I was just absolutely swamped.

Anyways, I've read through those links Josh posted and several other interfaces involved and I think I'm starting to get at least some idea of what's going on here.  I looks like what I need to do to start is make a new class that implements nsIInputStream, and wraps the MediaResource class so that we have a clean, controlled way of reading from the MediaResource and can use stream copier?


5 years ago
Mentor: cajbir.bugzilla
Whiteboard: [lang=c++][mentor=doublec] → [lang=c++]
Component: Audio/Video → Audio/Video: Playback

Comment 6

3 years ago
This sounds like something I would like to work on - of course, provided that it is still needed?
Flags: needinfo?(cajbir.bugzilla)
I'm not sure - Josh, do you have any insight here?
Flags: needinfo?(josh)

Comment 8

3 years ago
Certainly something has changed since comment 2 because I am no longer able to locate the code.
Looks like the files form comment 2 are in dom/media/android/ now:
Flags: needinfo?(josh)

Comment 10

3 years ago
Thanks Josh. Looking briefly at the code, I assume this is still relevant?
Maybe Anthony can answer that question, since he oversees the media team.
Flags: needinfo?(cajbir.bugzilla) → needinfo?(ajones)
Last Resolved: 3 years ago
Flags: needinfo?(ajones)
Resolution: --- → WONTFIX
This only affects older android versions. We're not going try to fix anything here.

Comment 13

3 years ago
Fair enough, I will find something else.
You need to log in before you can comment on or make changes to this bug.