Repository navigation
Flatten whole documents in one native pass and reuse the render bitmap - #162
balazs-szucs wants to merge 32 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Summary
Priority: ⬇️ Low Change: Feature Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: Stirling-Tools/JPDFium/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
1433d14e-61c5-4f56-940e-1a6f2fcfe42f
📒 Files selected for processing: 11
jpdfium/build.gradle.ktsjpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.javajpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javajpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javanative/bridge/include/jpdfium.hnative/bridge/src/jpdfium_redact.cppnative/bridge/src/jpdfium_render.cppnative/bridge/src/jpdfium_stub.cpp
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
📜 Review details
⏰ Context from checks skipped due to timeout: 20
- GitHub Check: prep-windows-icu
- GitHub Check: Corpus (generate + native)
- GitHub Check: CLI correctness & no-corruption tests
- GitHub Check: CodeQL Analysis (java-kotlin)
- GitHub Check: CodeQL Analysis (c-cpp)
- GitHub Check: JMH Benchmarks (FFM Downcall Overhead Gate)
- GitHub Check: Build & Verify (Compilation) (windows-latest)
- GitHub Check: Java - SpotBugs + Checkstyle + PMD + Spotless
- GitHub Check: Samples E2E Suite (All 88 Feature Samples)
- GitHub Check: Native bridge libFuzzer (ASan/UBSan, real PDFium)
- GitHub Check: CodeQL (java-kotlin)
- GitHub Check: Samples E2E (88 features via RunAllSamples)
- GitHub Check: build-natives (darwin-arm64, macos-14)
- GitHub Check: build-natives (darwin-x64, macos-15-intel)
- GitHub Check: build-natives (windows-arm64, windows-11-arm)
- GitHub Check: GraalVM Native Image Smoke & E2E Test (Linux x64)
- GitHub Check: build-natives (windows-x64, windows-latest)
- GitHub Check: Restricted-env compat (no execstack + hermetic bundle)
- GitHub Check: Flaky-test guard (3× rerun)
- GitHub Check: build-natives (linux-x64, ubuntu-latest)
🧰 Additional context used
📚 Code guidelines: 1
.github/CODERABBIT_REVIEW.md — configured
📓 Path-based instructions: 4
Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.
⚙️ CodeRabbit configuration file
Files:
native/bridge/src/jpdfium_stub.cppnative/bridge/src/jpdfium_redact.cppnative/bridge/include/jpdfium.hnative/bridge/src/jpdfium_render.cpp
Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.
⚙️ CodeRabbit configuration file
Files:
jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.
⚙️ CodeRabbit configuration file
Files:
jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javajpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java
Source excerpt: Use imports rather than package-qualified type names in method bodies and signatures.
📄 CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)
Files:
jpdfium/build.gradle.ktsnative/bridge/src/jpdfium_stub.cppjpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javanative/bridge/src/jpdfium_redact.cppjpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javajpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javanative/bridge/include/jpdfium.hjpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javanative/bridge/src/jpdfium_render.cppjpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java
a924595 to
94a25c1
Compare
94a25c1 to
dfb4d8e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🔇 Additional comments: 9
jpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.java: 1
58-82: LGTM!Also applies to: 85-86, 95-95, 103-103
native/bridge/src/jpdfium_render.cpp: 2
588-727: LGTM!
728-743: LGTM!Also applies to: 753-760
native/bridge/src/jpdfium_stub.cpp: 1
901-908: LGTM!jpdfium/build.gradle.kts: 1
505-511: LGTM!jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java: 1
1461-1481: LGTM!jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java: 1
5-159: LGTM!Also applies to: 179-181
jpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java: 1
1-221: LGTM!native/bridge/include/jpdfium.h-224-234: 1
224-234: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.State the partial-failure contract for
jpdfium_doc_flatten_annotations.The header says only the image pass leaves earlier pages changed after a failure.
jpdfium_doc_flatten_annotations(jpdfium_redact.cpp Lines 382-386) also returns after earlier pages were flattened, and it skips thegenerationbump on that path.PdfDocument.flattenalready treats both passes as possibly partial. Document the same contract for both functions so raw bridge callers do not assume the annotation pass is atomic.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: Stirling-Tools/JPDFium/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
299bccfe-c731-423b-9dfc-ae283a44cf5b
📒 Files selected for processing: 10
jpdfium/build.gradle.ktsjpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.javajpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javajpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javanative/bridge/include/jpdfium.hnative/bridge/src/jpdfium_redact.cppnative/bridge/src/jpdfium_render.cppnative/bridge/src/jpdfium_stub.cpp
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
📜 Review details
⏰ Context from checks skipped due to timeout: 27
- GitHub Check: build-natives (windows-arm64, windows-11-arm)
- GitHub Check: build-natives (darwin-x64, macos-15-intel)
- GitHub Check: build-natives (linux-musl-x64, ubuntu-latest, musl)
- GitHub Check: build-natives (linux-x64, ubuntu-latest)
- GitHub Check: build-natives (linux-arm64, ubuntu-24.04-arm)
- GitHub Check: build-natives (linux-musl-arm64, ubuntu-24.04-arm, musl)
- GitHub Check: build-natives (darwin-arm64, macos-14)
- GitHub Check: build-natives (windows-x64, windows-latest)
- GitHub Check: Restricted-env compat (no execstack + hermetic bundle)
- GitHub Check: Samples E2E Suite (All 88 Feature Samples)
- GitHub Check: JMH Benchmarks (FFM Downcall Overhead Gate)
- GitHub Check: Samples E2E (88 features via RunAllSamples)
- GitHub Check: GraalVM Native Image Smoke & E2E Test (Linux x64)
- GitHub Check: Build & Verify (Compilation) (windows-latest)
- GitHub Check: Bundle verify (symbols, RPATH, linkage, sizes)
- GitHub Check: Java - SpotBugs + Checkstyle + PMD + Spotless
- GitHub Check: Flaky-test guard (3× rerun)
- GitHub Check: build-natives (windows-arm64, windows-11-arm)
- GitHub Check: build-natives (windows-x64, windows-latest)
- GitHub Check: CodeQL (java-kotlin)
- GitHub Check: build-natives (darwin-x64, macos-15-intel)
- GitHub Check: Native bridge libFuzzer (ASan/UBSan, real PDFium)
- GitHub Check: Corpus (generate + native)
- GitHub Check: CLI correctness & no-corruption tests
- GitHub Check: CodeQL Analysis (c-cpp)
- GitHub Check: CodeQL (c-cpp)
- GitHub Check: CodeQL Analysis (java-kotlin)
🧰 Additional context used
📚 Code guidelines: 1
.github/CODERABBIT_REVIEW.md — configured
📓 Path-based instructions: 4
Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.
⚙️ CodeRabbit configuration file
Files:
native/bridge/src/jpdfium_stub.cppnative/bridge/include/jpdfium.hnative/bridge/src/jpdfium_redact.cppnative/bridge/src/jpdfium_render.cpp
Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.
⚙️ CodeRabbit configuration file
Files:
jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.
⚙️ CodeRabbit configuration file
Files:
jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javajpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javajpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java
Source excerpt: Use imports rather than package-qualified type names in method bodies and signatures.
📄 CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)
Files:
native/bridge/src/jpdfium_stub.cppjpdfium/build.gradle.ktsnative/bridge/include/jpdfium.hnative/bridge/src/jpdfium_redact.cppjpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javajpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javanative/bridge/src/jpdfium_render.cppjpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java
…acked # Conflicts: # jpdfium/build.gradle.kts
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: Stirling-Tools/JPDFium/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
069981eb-34f8-4391-a9f1-11f4d6b63e12
📒 Files selected for processing: 11
jpdfium/build.gradle.ktsjpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javanative/bridge/include/jpdfium.hnative/bridge/include/jpdfium_internal.hnative/bridge/src/jpdfium_redact.cppnative/bridge/src/jpdfium_render.cppnative/patch-pdfium-objtree-cache.pynative/setup-pdfium.sh
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
📜 Review details
⏰ Context from checks skipped due to timeout: 26
- GitHub Check: Bundle verify (symbols, RPATH, linkage, sizes)
- GitHub Check: Restricted-env compat (no execstack + hermetic bundle)
- GitHub Check: JMH Benchmarks (FFM Downcall Overhead Gate)
- GitHub Check: CodeQL Analysis (c-cpp)
- GitHub Check: Samples E2E Suite (All 88 Feature Samples)
- GitHub Check: Musl Native Detection (Alpine)
- GitHub Check: Build & Verify (Compilation) (windows-latest)
- GitHub Check: Flaky-test guard (3× rerun)
- GitHub Check: Samples E2E (88 features via RunAllSamples)
- GitHub Check: build-natives (darwin-arm64, macos-14)
- GitHub Check: GraalVM Native Image Smoke & E2E Test (Linux x64)
- GitHub Check: CodeQL Analysis (java-kotlin)
- GitHub Check: prep-windows-icu
- GitHub Check: Native bridge libFuzzer (ASan/UBSan, real PDFium)
- GitHub Check: CLI correctness & no-corruption tests
- GitHub Check: build-natives (linux-arm64, ubuntu-24.04-arm)
- GitHub Check: build-natives (darwin-x64, macos-15-intel)
- GitHub Check: build-natives (linux-x64, ubuntu-latest)
- GitHub Check: build-natives (windows-x64, windows-latest)
- GitHub Check: Natural System Libvips & Downstream Integration (Linux x64)
- GitHub Check: build-natives (windows-arm64, windows-11-arm)
- GitHub Check: Java - SpotBugs + Checkstyle + PMD + Spotless
- GitHub Check: Corpus (generate + native)
- GitHub Check: CodeQL (c-cpp)
- GitHub Check: CodeQL (java-kotlin)
- GitHub Check: JaCoCo coverage (non-blocking ratchet)
🧰 Additional context used
📚 Code guidelines: 1
.github/CODERABBIT_REVIEW.md — configured
📓 Path-based instructions: 4
Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.
⚙️ CodeRabbit configuration file
Files:
native/bridge/include/jpdfium_internal.hnative/bridge/include/jpdfium.hnative/bridge/src/jpdfium_redact.cppnative/bridge/src/jpdfium_render.cpp
Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.
⚙️ CodeRabbit configuration file
Files:
jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.
⚙️ CodeRabbit configuration file
Files:
jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javajpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java
Source excerpt: Use imports rather than package-qualified type names in method bodies and signatures.
📄 CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)
Files:
native/bridge/include/jpdfium_internal.hjpdfium/build.gradle.ktsnative/bridge/include/jpdfium.hnative/bridge/src/jpdfium_redact.cppnative/setup-pdfium.shjpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javanative/bridge/src/jpdfium_render.cppjpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javajpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javanative/patch-pdfium-objtree-cache.py
🪛 ast-grep (0.45.3)
native/patch-pdfium-objtree-cache.py
[warning] 15-15: File path is request-/variable-derived; validate and normalize to prevent path traversal.
Context: open(path, "r", encoding="utf-8")
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(open-filename-from-request)
[warning] 27-27: File path is request-/variable-derived; validate and normalize to prevent path traversal.
Context: open(path, "w", encoding="utf-8")
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(open-filename-from-request)
🪛 Ruff (0.16.8)
native/patch-pdfium-objtree-cache.py
[warning] 10-10: Use format specifiers instead of percent format
Replace with format specifiers
(UP031)
[warning] 14-14: Boolean default positional argument in function definition
(FBT002)
[warning] 15-15: Unnecessary mode argument
Remove mode argument
(UP015)
[warning] 20-20: for loop variable old overwritten by assignment target
(PLW2901)
[warning] 20-20: for loop variable new overwritten by assignment target
(PLW2901)
[warning] 22-22: Use format specifiers instead of percent format
(UP031)
[warning] 29-29: Use format specifiers instead of percent format
Replace with format specifiers
(UP031)
[warning] 139-139: Use format specifiers instead of percent format
Replace with format specifiers
(UP031)
🔇 Additional comments: 9
jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.java: 1
1001-1007: 🎯 Functional Correctness | ⚡ Quick winValidate
dpibefore thetryblock.If
dpi <= 0,docFlattenToImagesthrows before any native work runs. Thefinallyblock still callsinvalidateOpenPages(), so every openPdfPagebecomes stale although nothing changed. Checkdpibefore entering thetryblock.native/bridge/include/jpdfium.h: 1
236-246: LGTM!native/bridge/src/jpdfium_render.cpp: 1
738-770: LGTM!jpdfium/build.gradle.kts: 1
507-510: LGTM!jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java: 1
2691-2811: LGTM!jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java: 1
1461-1481: LGTM!jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java: 1
35-159: LGTM!native/setup-pdfium.sh: 1
1050-1055: LGTM!native/patch-pdfium-objtree-cache.py: 1
87-115: 🗄️ Data Integrity & IntegrationThe patch adds a per-document cache for
kReferenceHolderresults. ItsSetCachedObjectsWithMultipleReferencesandcached_objects_with_multiple_referencesaccessors store and return the set. Neither the inspected patch text nor the supplied file summary shows any code that clears the cache on document mutation. The cache is opt-in throughJPDFIUM_OBJTREE_CACHE.Whether a stale set is actually read depends on whether PDFium code calls
GetObjectsWithMultipleReferenceswithkReferenceHolderafter the sameCPDF_Documentis mutated. The PDFium source tree is not in the checkout. The shell search (fd -t d pdfium-src native) returned no PDFium directory. Thergsearch ofnative/matched onlynative/patch-pdfium-objtree-cache.py, so no caller or mutation path was inspected. The needed premise is the caller and mutation ordering in PDFium, and that evidence is unavailable.The missing-source limitation does not show the concern is false. It also does not show the risk is real. A reviewer should confirm the PDFium callers and mutation paths before this concern can be classified.
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: Stirling-Tools/JPDFium/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
1946efb2-9913-42f4-b830-883b9ebf67a0
📒 Files selected for processing: 14
jpdfium/build.gradle.ktsjpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.javajpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javajpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javanative/bridge/include/jpdfium.hnative/bridge/include/jpdfium_internal.hnative/bridge/src/jpdfium_redact.cppnative/bridge/src/jpdfium_render.cppnative/bridge/src/jpdfium_stub.cppnative/patch-pdfium-objtree-cache.pynative/setup-pdfium.sh
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
📜 Review details
🧰 Additional context used
📚 Code guidelines: 1
.github/CODERABBIT_REVIEW.md — unknown
📓 Path-based instructions: 4
Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.
⚙️ CodeRabbit configuration file
Files:
native/bridge/include/jpdfium_internal.hnative/bridge/src/jpdfium_stub.cppnative/bridge/src/jpdfium_redact.cppnative/bridge/include/jpdfium.hnative/bridge/src/jpdfium_render.cpp
Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.
⚙️ CodeRabbit configuration file
Files:
jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.
⚙️ CodeRabbit configuration file
Files:
jpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javajpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javajpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javajpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java
Source excerpt: Use imports rather than package-qualified type names in method bodies and signatures.
📄 CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)
Files:
native/bridge/include/jpdfium_internal.hjpdfium/build.gradle.ktsnative/bridge/src/jpdfium_stub.cppjpdfium/src/main/java/stirling/software/jpdfium/PdfDocument.javanative/bridge/src/jpdfium_redact.cppjpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.javanative/bridge/include/jpdfium.hnative/setup-pdfium.shjpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.javajpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.javanative/patch-pdfium-objtree-cache.pyjpdfium/src/main/java/stirling/software/jpdfium/doc/AnnotationType.javanative/bridge/src/jpdfium_render.cppjpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java
🪛 ast-grep (0.45.3)
native/patch-pdfium-objtree-cache.py
[warning] 15-15: File path is request-/variable-derived; validate and normalize to prevent path traversal.
Context: open(path, "r", encoding="utf-8")
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(open-filename-from-request)
[warning] 27-27: File path is request-/variable-derived; validate and normalize to prevent path traversal.
Context: open(path, "w", encoding="utf-8")
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(open-filename-from-request)
🪛 GitHub Check: Java - SpotBugs + Checkstyle + PMD + Spotless
jpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java
[warning] 137-137:
[try] auto-closeable resource page is never referenced in body of corresponding try statement
🪛 GitHub Check: JMH Benchmarks (FFM Downcall Overhead Gate)
jpdfium/src/jmh/java/stirling/software/jpdfium/bench/FlattenPathsBenchmark.java
[warning] 137-137:
[try] auto-closeable resource page is never referenced in body of corresponding try statement
🪛 Ruff (0.16.9)
native/patch-pdfium-objtree-cache.py
[warning] 10-10: Use format specifiers instead of percent format
Replace with format specifiers
(UP031)
[warning] 14-14: Boolean default positional argument in function definition
(FBT002)
[warning] 15-15: Unnecessary mode argument
Remove mode argument
(UP015)
[warning] 20-20: for loop variable old overwritten by assignment target
(PLW2901)
[warning] 20-20: for loop variable new overwritten by assignment target
(PLW2901)
[warning] 22-22: Use format specifiers instead of percent format
(UP031)
[warning] 29-29: Use format specifiers instead of percent format
Replace with format specifiers
(UP031)
[warning] 139-139: Use format specifiers instead of percent format
Replace with format specifiers
(UP031)
🔇 Additional comments: 11
native/bridge/src/jpdfium_render.cpp: 2
730-740: Release the old frame before you allocate a frame of a different size injpdfium_page_to_image.Lines 730-734 already destroy the old frame before creation. The remaining defect is different. If
FPDFBitmap_Createreturns null at Line 736,rasterFrameWidthandrasterFrameHeightare set to the requested size whilerasterFramestays null. Line 740 then returns an error, and no state becomes inconsistent. That path is acceptable.A separate defect remains. When
rasterize_page_intofails afterpage.reset(), the frame stays cached, so retention is bounded by the 32 MiB rule. No change is needed. Discard this comment.
758-790: LGTM!native/bridge/include/jpdfium.h: 1
236-245: LGTM!native/bridge/include/jpdfium_internal.h: 1
109-115: LGTM!native/bridge/src/jpdfium_redact.cpp: 1
444-463: LGTM!native/bridge/src/jpdfium_stub.cpp: 1
901-908: LGTM!jpdfium/build.gradle.kts: 1
189-189: LGTM!Also applies to: 507-510
jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumH.java: 1
2691-2811: LGTM!jpdfium/src/main/java/stirling/software/jpdfium/panama/JpdfiumLib.java: 1
1461-1481: LGTM!jpdfium/src/test/java/stirling/software/jpdfium/FlattenApiTest.java: 1
5-159: LGTM!Also applies to: 179-181, 230-241
native/patch-pdfium-objtree-cache.py: 1
62-65: 🩺 Stability & AvailabilityThe cache is enabled only through
JPDFIUM_OBJTREE_CACHE, but the available repository does not include the patched PDFium source or the callers ofGetObjectsWithMultipleReferences. The stale-cache behavior therefore cannot be decided from this checkout.
…and partial failure
…acked # Conflicts: # buildSrc/settings.gradle.kts
2454af4 to
70cd598
Compare
_sopen_s opened the staging file with the CRT's default text mode; _fdopen's "wb" does not switch an already-open descriptor, so every LF in the serialized PDF gained a CR. The added bytes shifted every offset past the first stream newline, so readers mis-resolved objects and reloaded page content streams came back empty (white pages); PDFBox masked it by reconstructing the xref, and the memory save path never touched the CRT file stream. Add _O_BINARY to both _sopen_s call sites.
6e9ad75 to
f38ce2f
Compare
The _sopen_s call fits on two lines once formatted; the dry-run lint job flagged the hand-wrapped version.
…acked Resolve the page-to-image rewrite against the batch flatten work: keep upstream's scratch-document generation so a malformed destination page tree cannot trap, import each finished replacement into the destination, and retain the batch pass's append-then-commit rollback plus the shared bounded raster frame. Remove the duplicated TurboJPEG CMake block, document the JPEG-quality switch and retained raster frame, and check the two new exports in CI.
5b62d3d to
9a4ef21
Compare
No description provided.