Skip to content

read Svg preview off the main Thread#21344

Open
Phoenix1808 wants to merge 1 commit into
ankidroid:mainfrom
Phoenix1808:fix/svg_preview_IO
Open

read Svg preview off the main Thread#21344
Phoenix1808 wants to merge 1 commit into
ankidroid:mainfrom
Phoenix1808:fix/svg_preview_IO

Conversation

@Phoenix1808

Copy link
Copy Markdown

Purpose / Description

When previewing a selected SVG in the multimedia image editor, the
SVG file is read on the main thread (loadSvgFromUri -> openInputStream
-> convertToString) before it's passed to the WebView. For a large SVG
or a slow document provider, this read can briefly block the UI.

This moves the read to Dispatchers.IO and keeps the WebView update on
the main thread. Behaviour is unchanged.

Fixes #21276

How Has This Been Tested?

Manually previewed SVG and non-SVG images in the multimedia image
editor; the preview renders as before. :AnkiDroid:compilePlayDebugKotlin
builds cleanly.

I didn't add an automated test: this is a threading change with no
observable behaviour difference, and there isn't existing infrastructure
to assert main-thread usage here. Happy to add one if you'd prefer a
specific approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential main-thread SVG stream read during multimedia image preview

1 participant