Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion app/src/main/java/app/opendocument/droid/ui/widget/PageView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ constructor(context: Context, attributeSet: AttributeSet?) :

private var wasCommitCalled = false

/** What [loadUrl] was last given: the only page whose failure is this document's. */
private var loadedUrl: String? = null

private var isBridgeAttached = false

init {
Expand All @@ -79,7 +82,12 @@ constructor(context: Context, attributeSet: AttributeSet?) :

buggyWebViewHandler.postDelayed(
{
if (!wasCommitCalled) {
// [url] and not whatever is loaded now: this callback can arrive after
// another page was asked for, which cancels the retries queued until
// then but not the one queued here. wasCommitCalled is about the page
// being waited on, so on its own it would answer for that other page
// and put this one back over it
if (!wasCommitCalled && url == loadedUrl) {
crashManager.log(RuntimeException("commit was not called"))

loadUrl(url)
Expand Down Expand Up @@ -316,6 +324,14 @@ constructor(context: Context, attributeSet: AttributeSet?) :
// the third party viewers an ONLINE result loads here. takes effect on the next load
if (!url.startsWith(JAVASCRIPT_SCHEME)) {
attachBridge(isOwnContent(url))

// a page that never committed left a retry waiting in onPageFinished. Now that another
// page has been asked for, that retry would load the old one back over it - and the
// document it belonged to has taken its server with it, so what it would find there is
// a 404 this page is then given up on for
buggyWebViewHandler.removeCallbacksAndMessages(null)
Comment thread
andiwand marked this conversation as resolved.

loadedUrl = url
}

super.loadUrl(url)
Expand All @@ -339,6 +355,13 @@ constructor(context: Context, attributeSet: AttributeSet?) :
return
}

// and only the page being shown. A request made for a document already closed can still be
// answered here, long after the page moved on, and the document on screen is not the one
// that failed
if (loadedUrl != null && url.toString() != loadedUrl) {
return
}

documentFragment.onPageFailed()
}

Expand Down
Loading