Catching OOM during widget preview generation

Bug: 32365481
Change-Id: Ifc49b033c3ad83213d50793301d94bb6337a412d
This commit is contained in:
Sunny Goyal committed 2016-10-27 11:39:14 -07:00
1 parent 9ccafbff26
commit 2570d107f5
1 file changed
+8 -1
@@ -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 {