mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 889564 - ANR: LightweightTheme.handleMessage can block the Gecko thread r=sriram
This commit is contained in:
parent
acae3ab917
commit
9c98375710
@ -7,6 +7,7 @@ package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -75,17 +76,25 @@ public class LightweightTheme implements GeckoEventListener {
|
||||
try {
|
||||
if (event.equals("LightweightTheme:Update")) {
|
||||
JSONObject lightweightTheme = message.getJSONObject("data");
|
||||
String headerURL = lightweightTheme.getString("headerURL");
|
||||
int mark = headerURL.indexOf('?');
|
||||
if (mark != -1)
|
||||
headerURL = headerURL.substring(0, mark);
|
||||
final String headerURL = lightweightTheme.getString("headerURL");
|
||||
|
||||
// Get the image and convert it to a bitmap.
|
||||
final Bitmap bitmap = BitmapUtils.decodeUrl(headerURL);
|
||||
mHandler.post(new Runnable() {
|
||||
// Move any heavy lifting off the Gecko thread
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setLightweightTheme(bitmap);
|
||||
String croppedURL = headerURL;
|
||||
int mark = croppedURL.indexOf('?');
|
||||
if (mark != -1)
|
||||
croppedURL = croppedURL.substring(0, mark);
|
||||
|
||||
// Get the image and convert it to a bitmap.
|
||||
final Bitmap bitmap = BitmapUtils.decodeUrl(croppedURL);
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setLightweightTheme(bitmap);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (event.equals("LightweightTheme:Disable")) {
|
||||
|
Loading…
Reference in New Issue
Block a user