Closed
Bug 910860
Opened 11 years ago
Closed 11 years ago
PNG decoder gets preferences off the main thread
Categories
(Core :: Graphics: ImageLib, defect)
Core
Graphics: ImageLib
Tracking
()
RESOLVED
FIXED
mozilla30
People
(Reporter: khuey, Assigned: milan)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 6 obsolete files)
The PNG decoder calls gfxPlatform::GetRenderingIntent. Since decoding now happens off the main thread we end up getting preferences there.
http://hg.mozilla.org/mozilla-central/annotate/21b5af569ca2/image/decoders/nsPNGDecoder.cpp#l557
https://tbpl.mozilla.org/php/getParsedLog.php?id=27186173&tree=Try#error0
Assignee | ||
Comment 1•11 years ago
|
||
Attachment #797491 -
Flags: review?(seth)
Assignee | ||
Comment 2•11 years ago
|
||
Kyle, is there a good way for me to push this to try with the changes needed to catch the problems?
Reporter | ||
Comment 3•11 years ago
|
||
You can grab what I pushed at https://hg.mozilla.org/try/rev/487c3c06b3af
Reporter | ||
Updated•11 years ago
|
Assignee: nobody → milan
Comment 4•11 years ago
|
||
Comment on attachment 797491 [details] [diff] [review]
Avoid getting CMS prefs on non-main thread.
Review of attachment 797491 [details] [diff] [review]:
-----------------------------------------------------------------
It looks like this is taking us down the right path, but we're not quite there yet.
::: gfx/thebes/gfxPlatform.cpp
@@ +110,5 @@
> +static bool gCMSPrefEnableV4 = false;
> +static bool gCMSPrefForceSRGB = false;
> +static int32_t gCMSPrefMode = -1;
> +static int32_t gCMSPrefIntent = -1;
> +static nsAdoptingCString gCMSPrefDisplayProfile;
Assigning an nsAdoptingCString isn't atomic on any platform. You need a lock to protect these variables.
I'd also prefer if you moved all of these variables into a class or struct using the singleton pattern. I'm not a big fan of static initializers. (Mostly this is a concern for gCMSPrefDisplayProfile, again, but may as well put them all in there.)
Attachment #797491 -
Flags: review?(seth) → review-
Assignee | ||
Comment 5•11 years ago
|
||
(In reply to Seth Fowler [:seth] from comment #4)
> Comment on attachment 797491 [details] [diff] [review]
> Avoid getting CMS prefs on non-main thread.
>
> Review of attachment 797491 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> It looks like this is taking us down the right path, but we're not quite
> there yet.
>
> ::: gfx/thebes/gfxPlatform.cpp
> @@ +110,5 @@
> > +static bool gCMSPrefEnableV4 = false;
> > +static bool gCMSPrefForceSRGB = false;
> > +static int32_t gCMSPrefMode = -1;
> > +static int32_t gCMSPrefIntent = -1;
> > +static nsAdoptingCString gCMSPrefDisplayProfile;
>
> Assigning an nsAdoptingCString isn't atomic on any platform. You need a lock
> to protect these variables.
Thanks that makes sense. I was just doing what the code was doing before, but that was not ready for multiple threads, so it makes sense that doing what was done before isn't enough.
>
> I'd also prefer if you moved all of these variables into a class or struct
> using the singleton pattern. I'm not a big fan of static initializers.
> (Mostly this is a concern for gCMSPrefDisplayProfile, again, but may as well
> put them all in there.)
I like that. I wasn't quite sure what pattern to follow in this file, but maybe I'll just go with "what's right" and not worry about matching the rest.
Assignee | ||
Comment 6•11 years ago
|
||
The fix to bug 912794 should take care of this.
Assignee | ||
Comment 8•11 years ago
|
||
The fix to bug 912794 will take care of this, but it's a bit messy fixing that bug. We can't do lazy evaluation of the preferences anymore, and while standard Firefox initializes gfxPlatform "first", some of the reftests do not. So, to make tests pass, we need to make the code look ugly. I'll post something in bug 912794 about this.
Flags: needinfo?(milan)
Assignee | ||
Comment 9•11 years ago
|
||
After bug 912794 lands, will ask for review.
Attachment #797491 -
Attachment is obsolete: true
Assignee | ||
Comment 10•11 years ago
|
||
Attachment #8373783 -
Attachment is obsolete: true
Assignee | ||
Comment 11•11 years ago
|
||
Will take care of the "only evaluate once" in bug 971126.
Attachment #8373795 -
Attachment is obsolete: true
Attachment #8376291 -
Flags: review?(bgirard)
Comment 12•11 years ago
|
||
Comment on attachment 8376291 [details] [diff] [review]
Use gfxPrefs to make sure preferences are evaluated on the main thread. This still leaves the preference re-evaluated.
Review of attachment 8376291 [details] [diff] [review]:
-----------------------------------------------------------------
See my review in https://bugzilla.mozilla.org/show_bug.cgi?id=946907#c5
Attachment #8376291 -
Flags: review?(bgirard) → review+
Assignee | ||
Comment 13•11 years ago
|
||
(In reply to Benoit Girard (:BenWa) from Bug 946907 comment #5)
> Comment on attachment 8375826 [details] [diff] [review]
> ...
> >
> > int
> > gfxPlatform::GetRenderingIntent()
> > {
> > if (gCMSIntent == -2) {
>
> Here -2 appears to mean 'I haven't read the property yet'. This is kind of
> ugly because a user could request -2 but fine because about:config is for
> power users anyways.
This was there before, and I think it's OK. After the inside of the if is called once (before or now), it is guaranteed not to be -2.
>
> maybe we should #define QCMS_INTENT_UNITIALIZE -2.
Are you thinking in qcms.h or in this file?
>
> This code should really initialize the preference to -1 (use embedded
> profile) and validate the range once when reading the preference simplifying
> this logic greatly. But I'm ok to r+ just with the -2 define if you're not
> looking to refactor this here.
>
>
> @@ +1656,5 @@
> > if (gCMSIntent == -2) {
> >
> > /* Try to query the pref system for a rendering intent. */
> > + int32_t pIntent = gfxPrefs::CMSRenderingIntent();
> > + if (pIntent != -2) {
>
> I don't think this 'if' here is needed. If it's not there line 1662 will
> reject -2 and we will initialize gCMSIntent to -1 and wont evaluate 1656 as
> true in the future.
>
Just to look at it all together.
Before the change:
If the preference is not set, GetRenderingIntent would return QCMS_INTENT_DEFAULT (which is 0).
If the preference is set to a value between 0 and 3, GetRenderingIntent would return the preference value.
If the preference is set outside of the range [0,3], GetRenderingIntent would return -1.
After the change:
If the preference is not set, gCMSIntent GetRenderingIntent would return QCMS_INTENT_DEFAULT (which is 0).
If the preference is set to a value between 0 and 3, GetRenderingIntent would return the preference value.
** If the preference is set to -2, gCMSIntent GetRenderingIntent would return QCMS_INTENT_DEFAULT (which is 0).
If the preference is outside of the range [0,3] and not -2, gCMSIntent GetRenderingIntent would return -1.
As you pointed out, the behavior ** where the user sets the preference to -2 is different than before.
However, if we get rid of the "if: you mentioned, I think we would get:
** If the preference is not set, gCMSIntent GetRenderingIntent would return -1.
If the preference is set to a value between 0 and 3, GetRenderingIntent would return the preference value.
If the preference is outside of the range [0,3] and not -2, gCMSIntent GetRenderingIntent would return -1.
So, in this case, we're changing the default behavior (preference not set) to go from default to embedded. Is that OK? If it is, it's probably a separate bug, because, well, the default is changing.
I could be reading the code wrong.
> ::: gfx/thebes/gfxPrefs.h
> @@ +102,5 @@
> > // This is where DECL_GFX_PREFS for each of the preferences should go.
> > // We will keep these in an alphabetical order to make it easier to see if
> > // a method accessing a pref already exists. Just add yours in the list.
> >
> > + DECL_GFX_PREFS(Live, "gfx.color_management.enablev4", CMSEnableV4, bool, false);
>
> Are you planning on later changing these to be Once? For example changing
> this pref in a running session will ignore CLUT tags from the output profile
> and current images but will honor them in any new images which will lead to
> inconsistent results.
Yup, this is bug 971126.
>
> @@ +103,5 @@
> > // We will keep these in an alphabetical order to make it easier to see if
> > // a method accessing a pref already exists. Just add yours in the list.
> >
> > + DECL_GFX_PREFS(Live, "gfx.color_management.enablev4", CMSEnableV4, bool, false);
> > + DECL_GFX_PREFS(Live, "gfx.color_management.mode", CMSMode, int32_t,- 1);
>
> nit: -1
Indeed, thanks.
Assignee | ||
Comment 14•11 years ago
|
||
Of course, a wee bit of refactoring would simplify this if we just set the default preference to 0. Let me put a patch together with that.
Assignee | ||
Comment 15•11 years ago
|
||
Attachment #8376412 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Attachment #8376291 -
Attachment is obsolete: true
Assignee | ||
Comment 16•11 years ago
|
||
Rebasing.
Attachment #8376412 -
Attachment is obsolete: true
Attachment #8377949 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 17•11 years ago
|
||
Keywords: checkin-needed
Comment 18•11 years ago
|
||
Backed out for xpcshell and reftest failures. Please run this through Try before requesting checkin next time.
https://hg.mozilla.org/integration/mozilla-inbound/rev/3ab5b318dcfc
https://tbpl.mozilla.org/php/getParsedLog.php?id=35054050&tree=Mozilla-Inbound
https://tbpl.mozilla.org/php/getParsedLog.php?id=35052378&tree=Mozilla-Inbound
Assignee | ||
Comment 19•11 years ago
|
||
Hmm, did in Comment 15 and only rebased to swap two different bugs around, but either way, guess didn't do it right.
Assignee | ||
Comment 20•11 years ago
|
||
Oh, I see, bug 972099 got backed out and I didn't notice. Add a direct dependency because this does depend on it.
Depends on: 972099
Assignee | ||
Comment 21•11 years ago
|
||
Attachment #8377949 -
Attachment is obsolete: true
Attachment #8386331 -
Flags: review+
Assignee | ||
Comment 22•11 years ago
|
||
Comment 23•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
You need to log in
before you can comment on or make changes to this bug.
Description
•