Closed Bug 1163215 Opened 9 years ago Closed 9 years ago

Make MediaFrame use <img> instead of background-image

Categories

(Firefox OS Graveyard :: Gaia::Gallery, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(b2g-v2.2 fixed, b2g-master fixed)

RESOLVED FIXED
2.2 S12 (15may)
Tracking Status
b2g-v2.2 --- fixed
b2g-master --- fixed

People

(Reporter: djf, Assigned: djf)

References

Details

Attachments

(1 file)

The MediaFrame class used to use <img> elements. Then we changed to use background-image because gecko was better at decoding those while offscreen.

Now, gecko should be smart enough to decode img elements when they are near the screen, and we're having memory issues possibly related to background images not being released soon enough.

So it is time to switch back to <img> elements in shared/js/media/media_frame.js.

Seth Fowler pointed out that we can still use a background-image on an <img> element to make the transition from preview to full-size image nice and smooth.  He even prepared a trial patch at: https://github.com/sethfowler/gaia/commit/d44816c000886cb549f08d02c18a5d8a169bbb81

So this bug is to either just land Seth's patch or to do something similar to that.

See also bug 1140619 for further discussion of why this is going to be necessary in the future anyway.

And see bug 1161734 for a 2.2+ bug that we're hoping this change will help with.
Assignee: nobody → dflanagan
Seth will investigate whether this bug blocks 2.2+ bug 1161734. If it does, then we'll have to uplift this.
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

Punam: please review this as soon as you can. It will probably be needed to resolve blocker bug 1161734. We're switching MediaFrame back to using <img> instead of background-image. As gecko evolves, the best way to display large images keeps changing.  Note that we're using background-image on a <img> element now, but only when the user zooms in. This gives us a way to start zooming with the preview image and then swap in the full-size image when it is ready.

Seth: please review from the platform standpoint. Does this look like it will help gecko better manage its image memory?  Note that I did not use your version of the patch here in part because yours is based on code that has already apparently removed the #-moz-samplesize media fragments, and I assume we're going to continue to need #-moz-samplesize on 2.2.
Attachment #8604338 - Flags: review?(seth)
Attachment #8604338 - Flags: review?(pdahiya)
(In reply to David Flanagan [:djf] from comment #3)
> Seth: please review from the platform standpoint. Does this look like it
> will help gecko better manage its image memory?  Note that I did not use
> your version of the patch here in part because yours is based on code that
> has already apparently removed the #-moz-samplesize media fragments, and I
> assume we're going to continue to need #-moz-samplesize on 2.2.

Yeah, that's correct. We are nearing the point where we won't need #-moz-samplesize on master, but that stuff won't get backported to 2.2.
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

r- only because it doesn't look like you're ever actually passing |bg| to |_displayImage|, as I mentioned on github.
Attachment #8604338 - Flags: review?(seth) → review-
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

Resetting the r? flag. See line 448 for the _displayImage() call that uses the new argument.

I'll update the typo in the comment before landing, but don't want to push a new commit now because it will probably restart the test run.
Attachment #8604338 - Flags: review- → review?(seth)
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

I did indeed just miss it. Thanks for pointing that out, David!
Attachment #8604338 - Flags: review?(seth) → review+
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

Hi David

The patch looks good and has my r+. Few nits noted in github about updating comments and with that patch looks good to land on master.

Another nit,  I noticed while testing the patch on nexus-4 is a subtle flicker when the image first loads in full-screen mode after clicking thumbnail which is not seen on master when using background-image.

Thanks!
Attachment #8604338 - Flags: review?(pdahiya) → review+
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

Punam,

I've updated the patch with the comment edits you pointed out, and have also made bigger changes:

1) the flickering was the broken image icon being displayed. I now set the opacity to 0 by default, then set it to 1 when I get a load event. I added CSS to gallery.css to make the opacity transition animated which gives a nice effect, I think.

2) I've changed MediaFrame to use only a single image element instead of creating a new one each time displayImage() is called. I hope that this will allow Gecko to discard old images more quickly than it would with the old code. This change is relatively large but might have a substantial impact on memory usage.

I've just noticed that there were some python test failures, probably due to the change of a div to an img, and I may have to push another version of the patch to make those work.  But you should be able to review these changes now.
Attachment #8604338 - Flags: review+ → review?(pdahiya)
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

Hi David

The updated patch looks good and has my r+. I see one python tests that's failing, with that fixed it should be good to land. Thanks!
Attachment #8604338 - Flags: review?(pdahiya) → review+
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

No-Jun: I'd like your review of the python test changes, please. I think I'm going to have to uplift this to 2.2, so there is some urgency about getting it landed.
Attachment #8604338 - Flags: review?(npark)
gallery tests ran locally, and they passed, and the changes themselves on the script looks okay to me as well.
Attachment #8604338 - Flags: review?(npark) → review+
Tests are finally green, and I've got all the reviews I need.
Keywords: checkin-needed
Seth: do you want this uplifted to 2.2 as part of your work on bug 1161734?
Flags: needinfo?(seth)
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
(In reply to David Flanagan [:djf] from comment #14)
> Seth: do you want this uplifted to 2.2 as part of your work on bug 1161734?

I think that's a good idea, yeah.
Flags: needinfo?(seth)
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

Josh,

Seth thinks that uplifting this patch will help resolve the 2.2+ blocker bug 1161734.

[Approval Request Comment]
[Bug caused by] (feature/regressing bug #): not a regression; this is just an adjustment to gaia to make it follow the changing fast paths in gecko.

[User impact] if declined: gallery app may use more memory and be less responsive.

[Testing completed]: locally

[Risk to taking this patch] (and alternatives if risky): this is not a trivial patch, but it is not a really complex one either. We're going to need to do lots of QA testing on the gallery app after bug 1161734 is resolved, and that should help us find any regressions introduced here.  Having said that, I don't think that this patch will introduce regressions.

[String changes made]: none
Attachment #8604338 - Flags: approval-gaia-v2.2?(jocheng)
Comment on attachment 8604338 [details] [review]
[gaia] davidflanagan:bug1163215 > mozilla-b2g:master

Hi Kevin

FYR about this patch related to bug 1161734.
Please help for regression test on Gallery app after this patch and bug 1161734 fix.

Thanks!
Flags: needinfo?(ktucker)
Attachment #8604338 - Flags: approval-gaia-v2.2?(jocheng) → approval-gaia-v2.2+
Adding qawanted per Comment 18.
Keywords: qawanted
No flashing thumbnails were observed when hundreds of pictures are present on the device but now there are large section of pictures(black areas) that appear to be missing on the Flame 2.2. 

Environmental Variables:
Device: Flame 2.2 (Full Flash)(KK)(319mb)
BuildID: 20150519002500
Gaia: 732acec6f37d13ccea6b0ddc48904a53a2970894
Gecko: 1389e6b8c065
Gonk: bd9cb3af2a0354577a6903917bc826489050b40d
Version: 37.0 (2.2) 
Firmware Version: v18D-1
User Agent: Mozilla/5.0 (Mobile; rv:37.0) Gecko/37.0 Firefox/37.0
Flags: needinfo?(ktucker)
Keywords: qawanted
Depends on: 1181290
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: