v136 · miscellaneous

Byte Budget Planner

Protected Audience bidding scripts have tight byte budgets for trusted signals. This planner mirrors protectedAudience.encodeUtf8() using browser-native TextEncoder, encodes your key-value pairs, tracks cumulative byte usage against the 256-byte limit, and generates the WASM memory layout a bidding script would use.

Chrome 136 adds protectedAudience.encodeUtf8(str) and protectedAudience.decodeUtf8(buffer) to Protected Audience bidding/scoring worklets. These mirror TextEncoder/TextDecoder but work inside the restricted worklet environment. This demo uses browser-native TextEncoder to preview the exact byte layout your bidding script would produce.

Key-value pairs (trusted signals)

Byte budget

0 / 256 bytes used

Signal analysis

KeyValueUTF-8 bytesCumulativeFits?
Add signals above.

Byte layout preview (first 256 bytes)

Bidding script pattern

// In a Protected Audience generateBid() worklet (Chrome 136+) function generateBid(interestGroup, auctionSignals, perBuyerSignals, trustedBiddingSignals, browserSignals) { // encodeUtf8 and decodeUtf8 available as protectedAudience globals const signals = {}; // Decode WASM-bound trusted signals for (const [key, value] of Object.entries(trustedBiddingSignals)) { const encoded = protectedAudience.encodeUtf8(value); // Pass to WASM: copyToWasmMemory(encoded, wasmMemory); // Decode response from WASM: const result = protectedAudience.decodeUtf8(wasmResultBuffer); signals[key] = result; } // Compute bid using decoded signals const cpm = parseFloat(signals.base_cpm || '0.5'); return { bid: cpm, ad: interestGroup.ads[0] }; } // Before Chrome 136: had to build TextEncoder shims manually // const enc = new TextEncoder(); // NOT available in PA worklets pre-136 // Chrome 136: protectedAudience.encodeUtf8 works natively in worklets