diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c700e6ad8..1dd3d1db5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ # UNRELEASED +### Frontend canister + +Sets the `ic_env` cookie for all HTML files only if the canister environment changed in the `commit_batch` method. + +- Module hash: c156183e6a6f5c3c71ecde5f38a7280b770ff172b4827127ef03b89b764065ba +- https://github.com/dfinity/sdk/pull/4446 + # 0.30.2 ### Improve frontend canister sync logic diff --git a/src/canisters/frontend/ic-certified-assets/src/state_machine/mod.rs b/src/canisters/frontend/ic-certified-assets/src/state_machine/mod.rs index db447cb5e2..8358cda7f3 100644 --- a/src/canisters/frontend/ic-certified-assets/src/state_machine/mod.rs +++ b/src/canisters/frontend/ic-certified-assets/src/state_machine/mod.rs @@ -732,6 +732,7 @@ impl State { system_context: &SystemContext, ) -> Result<(), String> { // Reload the canister env to get the latest values + let old_encoded_canister_env = self.encoded_canister_env.clone(); self.encoded_canister_env = system_context.get_canister_env().to_cookie_value(); let (chunks_added, bytes_added) = self.compute_last_chunk_data(&arg); @@ -753,7 +754,12 @@ impl State { self.batches.remove(&batch_id); self.certify_404_if_required(); - self.update_ic_env_cookie_in_html_files(); + // Only re-certify all HTML files if the canister environment changed. + // Assets modified in this batch already have the correct cookie via on_asset_change. + // Note: this can cause the canister to incur in the instructions limit with many assets. + if old_encoded_canister_env != self.encoded_canister_env { + self.update_ic_env_cookie_in_html_files(); + } self.last_state_update_timestamp_ns = system_context.current_timestamp_ns; Ok(()) diff --git a/src/distributed/assetstorage.wasm.gz b/src/distributed/assetstorage.wasm.gz index 5296f8bb33..6ebcb3285d 100755 Binary files a/src/distributed/assetstorage.wasm.gz and b/src/distributed/assetstorage.wasm.gz differ