Skip to content

switch to browser base64 methods#26

Closed
BwayCer wants to merge 1 commit into
gregzuro:masterfrom
BwayCer:feature/supportMobileDiagrams
Closed

switch to browser base64 methods#26
BwayCer wants to merge 1 commit into
gregzuro:masterfrom
BwayCer:feature/supportMobileDiagrams

Conversation

@BwayCer
Copy link
Copy Markdown

@BwayCer BwayCer commented Jul 17, 2025

Use native browser APIs to solve this issue.

@zero-gear
Copy link
Copy Markdown

The issue described in #8 was reproducible on my iPhone 12 Pro (no diagrams were rendered).

After applying this patch, all diagrams from kroki-test.md render correctly, except that the Diagrams.net type is still not rendered.

Thank you, @BwayCer — your changeset is both essential and very helpful for me.

@gregzuro
Copy link
Copy Markdown
Owner

Thanks @BwayCer — taken in 1.3.0 (#29, https://github.com/gregzuro/obsidian-kroki/releases/tag/1.3.0).

The implementation is slightly hardened from this PR: btoa(String.fromCharCode(...compressed)) can blow the call stack for large diagrams (the spread blows past the engine's argument limit), so the new code builds the binary string in 0x8000-byte chunks and then btoas once:

let binary = "";
const chunkSize = 0x8000;
for (let i = 0; i < compressed.length; i += chunkSize) {
    binary += String.fromCharCode(...Array.from(compressed.subarray(i, i + chunkSize)));
}
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_");

Same effect, won't choke on big diagrams. Closing — your fix is in the release.

@gregzuro gregzuro closed this May 14, 2026
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.

3 participants