Skip to content

fix: make embedded assets codegen and config serialization deterministic - #15777

Merged
Legend-Master merged 5 commits into
tauri-apps:devfrom
VityaSchel:dev
Aug 5, 2026
Merged

Legend-Master merged 5 commits into
tauri-apps:devfrom
VityaSchel:dev

Conversation

@VityaSchel

Copy link
Copy Markdown
Contributor

Hi, I'm developing an app with Tauri that requires reproducible builds. I found a non-determenistic build part that has to do with CSP. I have seen #14978 and #14986 but those didn't fix it fully.

  1. tauri-codegen: ToTokens for EmbeddedAssets emits the embedded asset map and the CSP script/style hash lists in the order the assets were collected, WalkDir traversal without sorting, i.e. raw readdir order. It differs on different machines with e.g. ext4 hashed directories so CspHash slice is different
  2. tauri-utils: the derived Serialize for Csp::DirectiveMap, HeaderSource::Map and PluginConfig writes HashMap key order, which is random per process. Tauri cli serializes processed config into the generated android project (assets/tauri.conf.json) so every build of the same source produces a differently ordered file

With this patched I was able to produce identical unsigned apks with Tauri with CSP enabled.

generate_context! emitted the embedded asset map and the CSP script/style
hashes in filesystem walk order (varies across machines) and HashMap
iteration order (varies per process), and serializing the processed config
wrote the csp/headers/plugins maps in HashMap iteration order. Both broke
reproducible builds: the same source built on two machines produced
different binaries and a different tauri.conf.json in the generated
Android project. Iterate all of them sorted, complementing tauri-apps#14986 which
sorted the same config maps on the ToTokens path.

closes tauri-apps#14978
@VityaSchel
VityaSchel requested a review from a team as a code owner July 25, 2026 13:58
@VityaSchel

Copy link
Copy Markdown
Contributor Author

Please let me know if you want any changes to this PR. Would love to have this shipped in coming versions as right now I have to either host a whole tauri-codegen source in my project's tree, add a patch-cargo dependency that works like patch-package in JS world or write complex shell scripts that do pretty much the same thing as patch-cargo but without third party tool.

VityaSchel added a commit to VityaSchel/open-grind that referenced this pull request Jul 25, 2026
@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Package Changes Through ad5f600

There are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-bundler with minor, tauri-build with minor, tauri-macos-sign with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor, @tauri-apps/api with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.11.1 2.12.0
tauri-utils 2.9.3 2.10.0
tauri-macos-sign 2.3.4 2.4.0
tauri-bundler 2.9.4 2.10.0
tauri-runtime 2.11.3 2.12.0
tauri-runtime-wry 2.11.4 2.12.0
tauri-codegen 2.6.3 2.7.0
tauri-macros 2.6.3 2.7.0
tauri-plugin 2.6.3 2.7.0
tauri-build 2.6.3 2.7.0
tauri 2.11.5 2.12.0
@tauri-apps/cli 2.11.4 2.12.0
tauri-cli 2.11.4 2.12.0
tauri-driver 2.0.6 2.1.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master Legend-Master added the status: waiting Waiting on author label Jul 28, 2026
@Legend-Master Legend-Master removed the status: waiting Waiting on author label Aug 4, 2026

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Legend-Master
Legend-Master merged commit 29c87c3 into tauri-apps:dev Aug 5, 2026
30 checks passed
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.

2 participants