Closed Bug 849495 Opened 7 years ago Closed 7 years ago

java.lang.IllegalArgumentException: x must be >= 0 at at org.mozilla.gecko.LightweightTheme.setLightweightTheme(


(Firefox for Android :: Theme and Visual Design, defect, critical)

20 Branch
Not set



Firefox 22
Tracking Status
firefox19 --- unaffected
firefox20 --- fixed
firefox21 --- fixed
firefox22 --- fixed


(Reporter: scoobidiver, Assigned: sriram)



(Keywords: crash, regression, Whiteboard: [native-crash][startupcrash])

Crash Data


(1 file)

It has been hit by two users several times at startup in 20.0b4. It's likely a regression from bug 816457.

Here is a crash report: bp-7d09acb4-ded0-4c0f-85d4-819f32130309.

java.lang.IllegalArgumentException: x must be >= 0
	at org.mozilla.gecko.LightweightTheme.setLightweightTheme(
	at org.mozilla.gecko.LightweightTheme.access$000(
	at org.mozilla.gecko.LightweightTheme$
	at android.os.Handler.handleCallback(
	at android.os.Handler.dispatchMessage(
	at android.os.Looper.loop(
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(
	at dalvik.system.NativeStart.main(Native Method)

More reports at:
Crash Signature: [@ java.lang.IllegalArgumentException: x must be >= 0 at] → [@ java.lang.IllegalArgumentException: x must be >= 0 at ]
Moore was right. Screen size and resolution double in size every two years!
Nexus 10 has a very large display with XXHDPI. The personas (with an "s") that are smaller than the screen-size will cause a crash while trying to crop them. <-- this would crash in Nexus 10.

While trying to fix it, I am confused. I can solve the crash (with effective checks). But, we cannot right align a bitmap, and show a color on the left. This will affect tiny buttons like Back, Tabs too. (If the image falls short and can't come under Tabs button, we should be showing a color).

What's expected here? We don't install images bigger than the screen-size? We try to squeeze in the image somehow?
(In reply to Sriram Ramasubramanian [:sriram] from comment #1)

> What's expected here? We don't install images bigger than the screen-size?
> We try to squeeze in the image somehow?

What would a stretched image look like? Why not use the dominant color for the left side?
The size of the image is small. <-- this gives an example of how much the image occupies in the entire UI.

Stretching is problem.
1. When the image is stretched for about:home, the same transformation should be applied for every small element. That doesn't sound feasible.
2. Even if we do (1), on patterns, there won't be any noticeable difference. But on personas carrying images like , the image will be too much distorted.

Dominant color to the left.
1. The image should be right aligned. The above screenshot does it. However, when an image is right aligned, it cannot be fed into a Shader of the Paint and drawn. If we cannot pass it through the shader, the image cannot blend into the background of dominant color.
2. In case of tabs button, this get even tricker! a. The image is half way through. b. There should be brown on the left. c. The resultant bitmap should be applied a LinearGradient (performance intensive). d. This LinearGradient (for alpha) Bitmap should be applied over a solid color.
Attached patch PatchSplinter Review
I found a better way. If the bitmap size is less than max-device-width, I create a canvas of size max-device-width X bitmap-height, paint it with dominant color and draw the original (smaller image) bitmap by top-right aligning it. There by, the bitmap is alteast as wide as the device that everything works fine.
Attachment #724149 - Flags: review?(mark.finkle)
The result will be like this:
Attachment #724149 - Flags: review?(mark.finkle) → review+
Comment on attachment 724149 [details] [diff] [review]

[Approval Request Comment]
Bug caused by (feature/regressing bug #): LWThemes.
User impact if declined: Personas will crash on Nexus 10 (and other big screen devices) when the size of the image is less than the size of the device.
Testing completed (on m-c, etc.): Landed in m-i on 03/13
Risk to taking this patch (and alternatives if risky): Very less. This makes sure the image is wide enough for the device.
String or UUID changes made by this patch: None.
Attachment #724149 - Flags: approval-mozilla-beta?
Attachment #724149 - Flags: approval-mozilla-aurora?
Assignee: nobody → sriram
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 22
Comment on attachment 724149 [details] [diff] [review]

low risk crash/regression fix - let's uplift.
Attachment #724149 - Flags: approval-mozilla-beta?
Attachment #724149 - Flags: approval-mozilla-beta+
Attachment #724149 - Flags: approval-mozilla-aurora?
Attachment #724149 - Flags: approval-mozilla-aurora+
Keywords: verifyme
You need to log in before you can comment on or make changes to this bug.