diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-04-24 16:16:49 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-04-24 16:16:49 +0100 |
commit | f76104c61bf4c3c5a092d08a1138ce79278aab76 (patch) | |
tree | 5f06b928d3bebeeb08909de133a72d726cc6d957 /android | |
parent | 02d561f29328dc827be3443e08bbe23bef367655 (diff) | |
download | mupdf-f76104c61bf4c3c5a092d08a1138ce79278aab76.tar.xz |
Fix crash in android app due to flood of page seeks.
Sebras found a way of crashing the MuPDF Android app by seeking
quickly back and forth with the page seek bar. After about 30
seconds of frantically tapping either end of it, we'd force close.
Examination shows this is due to the Async task queue getting full
and throwing an exception. A simple fix is to catch the exception
and perform the same tasks in the foreground.
Testing indicates that this causes the UI to stall, but it's far
preferable to a crash.
Diffstat (limited to 'android')
-rw-r--r-- | android/src/com/artifex/mupdf/MuPDFPageAdapter.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/android/src/com/artifex/mupdf/MuPDFPageAdapter.java b/android/src/com/artifex/mupdf/MuPDFPageAdapter.java index 91b30dce..4587e244 100644 --- a/android/src/com/artifex/mupdf/MuPDFPageAdapter.java +++ b/android/src/com/artifex/mupdf/MuPDFPageAdapter.java @@ -65,7 +65,21 @@ public class MuPDFPageAdapter extends BaseAdapter { pageView.setPage(position, result); } }; - sizingTask.execute((Void)null); + try + { + sizingTask.execute((Void)null); + } + catch (java.util.concurrent.RejectedExecutionException e) + { + // If we can't do it in the background, just + // do it in the foreground. + PointF result = mCore.getPageSize(position); + mPageSizes.put(position, result); + // Check that this view hasn't been reused for + // another page since we started + if (pageView.getPage() == position) + pageView.setPage(position, result); + } } return pageView; } |