Repository navigation
Open linearized files through the layer in layer mode - #111
Merged
Merged
Conversation
EmbedderTest::OpenDocumentHelper() took the FPDFAvail path for any linearized file, and only the other path went through LoadCustomDocumentForTest(), so in layer mode a test on a linearized fixture ran on a plain document: no copy-up door, no reads-dont-write check, and a write never showed up in its layer count. A linearized file now opens through the layer too; only a test that asks for linearized loading (LinearizeOption::kMustLinearize) keeps the FPDFAvail path. Plain mode is unchanged. Twenty tests on twelve fixtures move onto a layer. Five of them write and join the writers list. FPDFSaveEmbedderTest.SaveLinearizedDoc saved before the simulated download had fetched the metadata stream, so its expected bytes were a save that left object 26 out while the catalog still referred to it; it now makes the whole file available first, and plain and layer mode write the same bytes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed in the harness
EmbedderTest::OpenDocumentHelper()opened any file thatFPDFAvail_IsLinearized()accepts withFPDFAvail_GetDocument(), and only the other branch went throughembedpdf_test::LoadCustomDocumentForTest(). In layer mode (EPDF_EMBEDDER_LAYER_MODE=1) a test on a linearized fixture therefore ran on a plain document: no copy-up door, no reads-dont-write check, andEPDFLayer_GetPromotedObjectCount()read 0, so it never showed up as a writer.Now, in layer mode, a linearized file opens through the layer like any other file. Only a test that asks for linearized loading (
LinearizeOption::kMustLinearize, i.e.OpenDocumentLinearized()) keeps the FPDFAvail path. Plain mode is unchanged.Why that rule: the tests that need progressive loading either ask for it (
LoadMainCrossRefTable,LinearizedDocument,Hang1055,PasswordAfterGenerateSave) or build their ownFPDF_AVAIL(CreateAvail()+SetDocumentFromAvail(): the data-avail tests andCPDFCreatorEmbedderTest.SaveLinearizedInfo). No test opens a linearized file with the default option and then relies onavail()or the hint tables;GetPageCount()andGetFirstPageNum()already run on non-linearized files.FPDFAvail_IsLinearized()also checks that/Lequals the file length, so 12 of the 14 fixtures that start with/Linearizedtake this path.annotation_stamp_with_ap.pdfandbug_781804.pdfwere saved incrementally after linearizing and already opened through the layer.Tests that moved onto a layer
20 tests on 10 fixtures (the other two linearized fixtures are only opened with
kMustLinearize). All pass in layer mode.New writers, added to
testing/embedpdf_layer_mode_writers.txt:EPDFAnnotEmbedderTest.RefitWrapsAStampAcrobatTurnedUprightEPDFPageLabelsEmbedderTest.NoSectionsRemovesTheLabelsEPDFPageLabelsEmbedderTest.RefusesSectionsThatBreakTheRulesRichTextParityTest.BorderWidthsFixtureMatchesAcrobatRichTextParityTest.CalloutWidthsFixtureMatchesAcrobatRefusesSectionsThatBreakTheRuleswrites once, at its end; its refusals return before any mutable access. The RichText parity counts are 2 per annotation (annotation + appearance stream), as in the other parity tests.Now checked as readers (0 objects):
CPDFParserEmbedderTest.Bug757705; sevenCPDFSecurityHandlerEmbedderTesttests onencrypted.pdf(BadPassword,NoPassword,UserPassword,OwnerPassword,SetRuntimeOwnerPermissions,CheckPasswordPermissionsDoesNotUnlockOwner,CheckPasswordPermissionsIgnoresCurrentOwnerUnlockState);EPDFAnnotEmbedderTest.AppearanceTransformOfAStampAcrobatTurned;EPDFAnnotEmbedderTest.UnrotatedRenderUndoesATurnDrawnInTheStream;EPDFMeasureEmbedderTest.ReadsAllAcrobatImperialMeasurementsandReadsAllAcrobatMetricMeasurements;EPDFPageLabelsEmbedderTest.ReadsTheSectionsOfAFile;FPDFDocEmbedderTest.GetPageLabels;FPDFSaveEmbedderTest.SaveLinearizedDoc.CPDFSecurityHandlerEmbedderTest.PasswordAfterGenerateSavewrites but asks for linearized loading, so it stays plain; it now says so in a comment.Layer bugs
None found. One test changed:
FPDFSaveEmbedderTest.SaveLinearizedDocfailed only in layer mode, and the plain run was the wrong one. The test saved before the simulated download had fetched the metadata stream, so the save left object 26 out (a free entry) while the catalog still said/Metadata 26 0 R. Its byte expectations (0000000026 65535 f, 7912 bytes) described that dangling save. The test now callsSetWholeFileAvailable()first, asSaveLinearizedInfodoes, and checks that object 26 is written. Plain and layer mode now write the same 10982 bytes.Tests (macOS arm64, against
embedpdf/main538900d)run_layer_mode.pyover the whole embedder suite (1780 tests): writers 500 on main, 505 here; the per-test object counts differ only in the five tests above. Pass/fail/crash counts are the same as main (1555/40/185, all matched byembedpdf_layer_mode_expectations.txt).CaptionAppearanceGolden). The independent save checker passed (49 PDFs).pdfium_unittestshas none of the changed files as inputs.pdfium_testhas none of the changed files as inputs, so it is the same binary as main's.Note for #110
With this change,
text_rich_comment_acrobat.pdf(#110's fixture) opens through the layer. Measured on a scratch merge of both:EPDFAnnotEmbedderTest.AcrobatCommentWrittenBackReadsTheSamewrites 1 object,AcrobatNoteCommentReadsAsRichTextreads clean. Whichever of the two merges second needsEPDFAnnotEmbedderTest.AcrobatCommentWrittenBackReadsTheSame 1in the writers list.