Bug 695132

Summary: MuPDF Library throwing sporadic exception on Android
Product: MuPDF Reporter: Marcos H. Woehrmann <marcos.woehrmann>
Component: mupdfAssignee: Paul Gardiner <paul.gardiner>
Status: NOTIFIED FIXED    
Severity: normal CC: cs, matt, tor.andersson
Priority: P2    
Version: 1.3   
Hardware: Android Phone   
OS: Android   
Customer: 832 Word Size: ---

Description Marcos H. Woehrmann 2014-04-02 13:07:32 UTC
The customer reports:

We are experiencing production crashes in our app while using the 1.3 version of the MuPDF library.  The exception stack trace is:

20140326 110428 PDT:HockeyExceptionHandler:uncaughtException:Received uncaught exception.
java.lang.UnsupportedOperationException: Not supported
	at com.artifex.mupdfdemo.ReaderView.getSelectedView(ReaderView.java:660)
	at android.widget.AdapterView.onInitializeAccessibilityEvent(AdapterView.java:951)
	at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:4946)
	at android.view.View.sendAccessibilityEventUnchecked(View.java:4933)
	at android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.run(ViewRootImpl.java:6675)
	at android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.runOrPost(ViewRootImpl.java:6701)

This does appear to happen quite frequently on a Nexus 5 we have in house, but for all other cases we've experienced the crash, we can't reproduce it.

The code from the stack trace for getSelectedView() is the following.  Do you know why Android seems to call this method, thus causing the UnsupportedOperationException?

ReaderView.java:
@Override
public View getSelectedView() {
  throw new UnsupportedOperationException(getContext().getString(R.string.not_supported));
}
Comment 1 cs 2014-04-03 07:20:31 UTC
Bug fixed:

just comment this line and return null

	@Override
	public View getSelectedView() {
		//throw new UnsupportedOperationException(getContext().getString(R.string.not_supported));
        	return null;
	}


newscope GmbH
Comment 2 Matt Holgate 2014-06-18 04:10:06 UTC
This is easy to reproduce if you enable 'Talkback' in the accessiblity settings. 

The fix should be pretty straightforward.
Comment 3 Matt Holgate 2014-06-18 04:11:50 UTC
Actually, cs@newscope.com has supplied the fix, thanks!
Comment 4 Matt Holgate 2014-06-18 05:44:07 UTC
commit 38402bcf8dfea7b08cb5b3e6948af078d0b3874b
Author: Matt Holgate <matt@emobix.co.uk>
Date:   Wed Jun 18 12:21:05 2014 +0100

    Fix bug #695132: MuPDF Library throwing sporadic exception on Android

    Android sometimes calls the 'getSelectedView()' method of an AdapterView.
    This can be made to happen more predicatably by enabling the Talkback
    accessibility feature.

    Remove the UnsupportedOperationException and just return null, as we the
    ReaderView does not have the concept of a selected page.