Skip to content

Conversation

@mickael-menu
Copy link
Member

Fixed

Streamer

  • Fixed the rendering of PDF covers in some edge cases.

@mickael-menu mickael-menu requested a review from qnga December 3, 2021 14:07
Comment on lines -58 to -59
val pointer = openPage(document, 0)
if (pointer <= 0) return null
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I checked for the pointer to be above 0, but sometimes it is negative and still valid. This prevented a few PDF covers to be rendered on some devices.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 is supposed to be an invalid pointer. I'm not sure the method can return it here though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's weird. Maybe the openPage() fails for some reason, but that doesn't prevent the rest of the code from working as we don't use the pointer directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose in case of failure you won't get the first page though...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice yes, but that's not guaranteed... I will look again on Friday to see if I can find a better way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qnga I investigated more and looking at the Java and C++ code of PdfiumAndroid, I don't think the returned long is the address of a C++ pointer. I also tried giving a non-existing page index and this function throws an exception, so the error handling is properly handled inside.

So I think this PR is safe to merge as is. We also used this code in production for the past two weeks without bug reports.

@mickael-menu mickael-menu merged commit 62d675f into readium:develop Dec 17, 2021
@mickael-menu mickael-menu deleted the fix/pdf-cover branch December 17, 2021 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants