Closed Bug 1322501 Opened 8 years ago Closed 3 years ago

Asynchronously obtain, send, and store image data from Gecko to Java

Categories

(Firefox for Android Graveyard :: Activity Stream, defect, P3)

defect

Tracking

(fennec+, firefox57 affected)

RESOLVED INCOMPLETE
Tracking Status
fennec + ---
firefox57 --- affected

People

(Reporter: Grisha, Unassigned)

References

Details

(Whiteboard: [MobileAS] 1.26 1.27)

Attachments

(1 file)

For Activity Stream, we need to display highlight preview images. There's a high chance that an image we'd like to display is already available via Gecko's cache.

Obtaining image data itself is easy enough, and can be achieved via performing a network request to fetch it, setting correct cache flags so that request is fulfilled via cache, possibly without validation.

The second step is sending image data over to Java.
Priority: -- → P2
Whiteboard: [MobileAS]
Rank: 1
Whiteboard: [MobileAS] → [MobileAS] 1.26
Iteration: --- → 1.26
Priority: P2 → P1
Iteration: 1.26 → 1.27
Whiteboard: [MobileAS] 1.26 → [MobileAS] 1.26 1.27
Assignee: nobody → michael.l.comella
Now that I've dug in a little, I've realized that this is an optimization of bug 1301718, which is basically to do this in Java first. So unassigning to focus on the other bug first.

I've made decent progress: I was able to get a reference to the nsICacheEntry for a given URL, from which we can get an inputStream. I'll upload my scratchpad after this. On IRC, jchen suggested passing a reference to Java of the memory that the inputStream is pointing to and writing a custom InputStream in Java that decodes that data (which may be similar to how ThumbnailHelper does it):

17:52
<mcomella> jchen: I'm trying to send a cached image from Gecko -> Java: do you have any tips? I have an nsICacheEntry, which can give me an inputstream and I can also use imgITools.decodeImage to turn it into a an imgIContainer. However, I can't seem to find 1) the raw data or 2) the path on disk, which I think I need to pass one of to Java. This is part of
17:52 https://bugzilla.mozilla.org/show_bug.cgi?id=1322501
18:03 
<jchen> mcomella: i guess one way is to read the image data from the inputstream and copy the raw data to java (similar to ThumbnailHelper)
18:04 
<jchen> mcomella: you can implement an inputstream in java that does the bytebuffer transfer behind the scenes, and decode the image in java using your java inputstream
18:06 
<mcomella> Michael Comella jchen: So rather than passing the data over the gecko bridge, you're suggesting I should pass a reference to the buffer where the data is stored and decode it in java using a custom inputstream?
18:06 *"the data" being the raw bytes of the image data
18:06 From gecko
18:06 
<jchen> something like that

---

Notes:
- nsICacheEntry & friends are best looked up via dxr, filtering on idl files, e.g.: https://dxr.mozilla.org/mozilla-central/search?q=path%3Anetwerk%2Fcache2%2F*.idl&redirect=false
- about:cache is very helpful for seeing what's in your cache, its metadata, and getting a reference to a cached entry for testing
Assignee: michael.l.comella → nobody
No longer blocks: 1301718
Depends on: 1301718
Actually, since this is just an optimization, I'm going to reflag it for triage.
tracking-fennec: --- → ?
Summary: Asynchronously obtain and send image data from Gecko to Java → Asynchronously obtain, send, and store image data from Gecko to Java
Priority: P1 → --
Depends on: 1388415
Iteration: 1.27 → 1.28
Iteration: 1.28 → ---
Priority: -- → P2
Bumping this to P3, filing a smaller bug to download just over wifi.

mcomella, can you add the dependency when you file the other bug?
Flags: needinfo?(michael.l.comella)
Priority: P2 → P3
Flags: needinfo?(michael.l.comella)
All open Activity Stream bugs are moving from the whiteboard tag, "[mobileAS]", to the Firefox for Android component, "Activity Stream", so that I can keep better track of these bugs as the new triage owner; I will send out an email shortly with additional details, caveats, etc.
Component: General → Activity Stream
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: