Merge "Catching OOM during widget preview generation" into ub-launcher3-master

This commit is contained in:
Sunny Goyal
2016-10-27 22:04:51 +00:00
committed by Android (Google) Code Review

View File

@@ -301,7 +301,14 @@ public class WidgetPreviewLoader {
Drawable drawable = null;
if (info.previewImage != 0) {
drawable = mWidgetManager.loadPreview(info);
try {
drawable = mWidgetManager.loadPreview(info);
} catch (OutOfMemoryError e) {
Log.w(TAG, "Error loading widget preview for: " + info.provider, e);
// During OutOfMemoryError, the previous heap stack is not affected. Catching
// an OOM error here should be safe & not affect other parts of launcher.
drawable = null;
}
if (drawable != null) {
drawable = mutateOnMainThread(drawable);
} else {