Closed Bug 1255335 Opened 5 years ago Closed 5 years ago

crash in java.lang.NullPointerException: Attempt to invoke virtual method ''int android.graphics.Bitmap.getWidth()'' on a null object reference at android.graphics.Bitmap.createScaledBitmap(Bitmap.java)

Categories

(Firefox for Android Graveyard :: Favicon Handling, defect)

Unspecified
Android
defect
Not set
critical

Tracking

(firefox45 unaffected, firefox46 unaffected, firefox47 verified, firefox48 verified)

VERIFIED FIXED
Firefox 48
Tracking Status
firefox45 --- unaffected
firefox46 --- unaffected
firefox47 --- verified
firefox48 --- verified

People

(Reporter: cos_flaviu, Assigned: ahunt)

References

Details

(Keywords: crash, regression, reproducible)

Crash Data

Attachments

(2 files)

This bug was filed from the Socorro interface and is 
report bp-9f922d4a-0971-4341-9d7b-b6b532160310.
=============================================================

Environment: 
Device: Asus ZenPad 8 (Android 5.0.2);
Build: Nightly 48.0a1 (2016-03-09);

Steps to reproduce:
1. Go to a website that does not have favicon (e.g.: http://mozqa.com/data/firefox/geolocation/wifi.html);
2. Bookmark the page;
3. Tap Options on the snack bar;
4. Tap on Add to Home Screen option.

Expected result:
The page is successfully added to home screen.

Actual result:
Fennec crashes.

Stack trace:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
	at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:596)
	at org.mozilla.gecko.favicons.LoadFaviconTask.processResult(LoadFaviconTask.java:579)
	at org.mozilla.gecko.favicons.LoadFaviconTask.onPostExecute(LoadFaviconTask.java:547)
	at org.mozilla.gecko.favicons.LoadFaviconTask$1$1.run(LoadFaviconTask.java:326)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5257)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Looks like bug 1238656.

Andrzej, do you know what's up?
Blocks: 1238656
Flags: needinfo?(ahunt)
We introduced the "if ((flags & FLAG_BYPASS_CACHE_WHEN_DOWNLOADING_ICONS) != 0)" check,
and direct Bitmap scaling in Bug 1238656 to avoid getting the cached icon (which results
in downscaling) for apple-touch-icons (or just any icon that we're using for homescreen shortcuts).
However we need to make sure we can actually scale the icon before performing scaling, hence
this check should have been within our pre-existing "if (image_params_are_valid)" clause.

Review commit: https://reviewboard.mozilla.org/r/39409/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39409/
Attachment #8729370 - Flags: review?(s.kaspari)
Assignee: nobody → ahunt
Comment on attachment 8729370 [details]
MozReview Request: Bug 1255335 - Ensure we can and should scale image before scaling r?sebastian

https://reviewboard.mozilla.org/r/39409/#review36361

::: mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java:552
(Diff revision 1)
>      private void processResult(Bitmap image) {
>          Favicons.removeLoadTask(id);
>          final Bitmap scaled;
>  
>          // Notify listeners, scaling if required.
> +        if (targetWidthAndHeight != -1 && image != null &&  image.getWidth() != targetWidthAndHeight) {

Nit: Two spaces in front of image.getWidth()
Attachment #8729370 - Flags: review?(s.kaspari) → review+
Crash Signature: [@ java.lang.NullPointerException: Attempt to invoke virtual method ''int android.graphics.Bitmap.getWidth()'' on a null object reference at android.graphics.Bitmap.createScaledBitmap(Bitmap.java)] → [@ java.lang.NullPointerException: Attempt to invoke virtual method ''int android.graphics.Bitmap.getWidth()'' on a null object reference at android.graphics.Bitmap.createScaledBitmap(Bitmap.java)] [@ java.lang.NullPointerException: at android.graphics.B…
Flags: needinfo?(ahunt)
Comment on attachment 8729370 [details]
MozReview Request: Bug 1255335 - Ensure we can and should scale image before scaling r?sebastian

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39409/diff/1-2/
https://hg.mozilla.org/integration/fx-team/rev/b44597ac0648eabfb42ef8aea30b5bbf4e73328f
Bug 1255335 - Ensure we can and should scale image before scaling r=sebastian
Comment on attachment 8729370 [details]
MozReview Request: Bug 1255335 - Ensure we can and should scale image before scaling r?sebastian

Approval Request Comment
[Feature/regressing bug #]: Bug 1238656
[User impact if declined]: Crashes with some sites (if we try to scale a non-existing favicon)
[Describe test coverage new/current, TreeHerder]: Manual testing locally.
[Risks and why]: Low risk - brings back null-checks for all cases of image scaling, that were moved to the wrong location 1238656.
[String/UUID change made/needed]: None

We might want to uplift Bug 1238656 to Beta, in which case we'd have to uplift this fix too.
Attachment #8729370 - Flags: approval-mozilla-aurora?
https://hg.mozilla.org/mozilla-central/rev/b44597ac0648
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
Comment on attachment 8729370 [details]
MozReview Request: Bug 1255335 - Ensure we can and should scale image before scaling r?sebastian

crash fix, taking it. Aurora47+
Attachment #8729370 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Verified as fixed in build 48.0a1 (2016-03-17);
Device: Asus ZenPad 8 (Android 5.0.2).
has problems uplifting to aurora

Tomcats-MacBook-Pro-2:mozilla-central Tomcat$ hg graft --edit -r b44597ac0648
grafting 334457:b44597ac0648 "Bug 1255335 - Ensure we can and should scale image before scaling r=sebastian"
merging mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
warning: conflicts while merging mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java! (edit, then use 'hg resolve --mark')
abort: unresolved conflicts, can't continue
(use hg resolve and hg graft --continue)
Flags: needinfo?(ahunt)
(In reply to Carsten Book [:Tomcat] from comment #11)
> has problems uplifting to aurora
> 
> Tomcats-MacBook-Pro-2:mozilla-central Tomcat$ hg graft --edit -r b44597ac0648
> grafting 334457:b44597ac0648 "Bug 1255335 - Ensure we can and should scale
> image before scaling r=sebastian"
> merging
> mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
> warning: conflicts while merging
> mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java!
> (edit, then use 'hg resolve --mark')
> abort: unresolved conflicts, can't continue
> (use hg resolve and hg graft --continue)

Looks like I got hit by a variable rename in:
https://hg.mozilla.org/integration/fx-team/rev/d8c0657ff5d3

Here's a patch that applies to aurora!
Flags: needinfo?(ahunt)
Verified as fixed in build 47.0a2 2016-03-25;
Device: Asus ZenPad 8 (Android 5.0.2).
Status: RESOLVED → VERIFIED
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.