[A/B/C] Fix document close ANR & gesture conflict#84
Conversation
- Category: A/B/C — Performance & UI Polish - Files: PdfViewerViewModel.kt, PdfViewerScreen.kt - Build: PASS - Tests: SKIPPED - Emulator: SKIPPED - Risk: LOW Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🔧 Weekly Performance Optimization — 2025-05-22
Category: A/B/C — Bug Fix, Performance, UI Polish
What Changed
This PR optimizes the
PdfViewerViewModelto perform document closing operations off the main thread, mitigating potential ANR crashes. Additionally, it refines gesture processing in thePdfViewerScreenso that vertical panning while zoomed doesn't conflict with scrolling through the pages list.Technical Details
PdfViewerViewModel.loadPdf(), thecloseDocument()call previously occurred inside theviewModelScope.launchbody (on the Main dispatcher), which could block the UI thread during disk-heavy PDF closures. It's now correctly placed insidewithContext(Dispatchers.IO).PdfViewerScreen.kt, theLazyColumn'suserScrollEnabledattribute has been updated to requirescale <= 1f. This ensures that when the user has zoomed into a page, vertical swiping results in panning within that zoomed page, instead of scrolling to the next document page.Files Changed
app/src/main/java/com/yourname/pdftoolkit/ui/screens/PdfViewerViewModel.kt: Moved document closure logic to the IO dispatcher.app/src/main/java/com/yourname/pdftoolkit/ui/screens/PdfViewerScreen.kt: DisabledLazyColumnscrolling whenscale > 1f.Performance Impact
Expected improvement in stability (no ANRs on document loading/closing) and significantly enhanced user experience when manipulating zoomed pages.
Verification
./gradlew assembleFdroidDebug— PASSED ✅./gradlew test— SKIPPED ⏭️android layoutRisk Level: LOW
PR created automatically by Jules for task 1960937812046719240 started by @Karna14314