Repository navigation
Feat: Lazy font assets that load on the first missing glyph (FR-48.4) - #1084
Merged
Merged
Conversation
…ph (#1057) Draft. Reserves FontRef kind 4, event 71 and payload type 46 in the leader ledger; implementation follows on this branch.
# Conflicts: # compose-rust/src/codegen.rs # compose-rust/tests/vectors/mutations.bin
develop's ButtonKind and CR-8a's Count both took bit 62 of the writer's sent-property mask, which the turn-2 merge resolved by moving Count to 61. A node that wrote one would have seen the other as already sent. No widget takes both today; the test keeps the bits distinct and checks that one never clears the other.
…FR-48.4) The Host half of lazy font assets. - FontRef::LazyAsset(id), kind 4 (FONT_REF_LAZY_ASSET), encoded and decoded like Asset, and the generated Kotlin FontRef.LazyAsset. - FontStack::lazy_family(ids): a stack with a lazy family is written as version 2, with a kind word (1 or 4) before each family's face count. A stack without one stays version 1, byte for byte. - lazy_asset(AssetKind::Font, bytes) returns the id asset() would give the same bytes and registers nothing. Bytes already registered give that id; asset() on set-aside bytes later registers them under the id lazy_asset gave. - Event AssetWanted, tag 71, payload type 46 (asset_id u32), a 20 byte record. The Host answers it with the existing RegisterAsset on the batch the event returns. An unknown id queues nothing and is one ProtocolError::UnknownAsset; a node or handler id is refused. After release_asset(id) a later AssetWanted(id) sends the bytes again under the same id. Tests: fr10_lazy_asset_font_ref_round_trips (criterion 6, Rust side), fr48_4_lazy_face_bytes_stay_on_the_host (criterion 1), and the Host rules in fr48_4_asset_wanted_registers_the_set_aside_face_on_the_next_batch, fr48_4_an_unknown_asset_wanted_is_one_protocol_error, fr48_4_a_released_lazy_face_is_sent_again_when_wanted and fr48_4_lazy_asset_gives_the_id_asset_would. Not compiled locally. The generated files are not in this commit: Protocol.gen.kt (desktop and android-kotlin), schema-hash.txt and tests/vectors are produced by the codegen binary. The schema hash moves and events.bin grows from 1835 to 1855 bytes; the length checks in the Rust and Kotlin tests are updated for that.
…FR-48.4) The Renderer half of lazy font assets, in the interpreter Android and iOS share. - A LazyAsset candidate without bytes, and a lazy stack family (stack version 2) whose faces have not all arrived, is a pending chain member. It takes every letter that reaches it, so no letter falls past it to a later candidate, the bundled fallback faces or the machine's fonts. - A letter that reaches a pending member asks for its ids through the asset cache, once per id until a ReleaseAsset of it. The requests go out as AssetWanted(id) at the top of the next frame, never from inside a composition or a measure call. - Until the bytes arrive the letter is drawn from a missing glyph face: a small TrueType font built in process for exactly the letters of the span (a box, a blank for white space, nothing for marks and invisible format characters), read through the platform's own font loader. Measuring and drawing ask for the same letters and get the same face. - When the face arrives the candidate is Asset(id). Lists are resolved again on the next composition; a stack naming the face lazily is read again into a new chain, so theme text is measured and drawn again too. A release makes the member pending again. Tests (renderer/desktop/test/LazyFontTest.kt, ProtocolVectorsTest.kt): fr48_4_missing_glyph_loads_the_lazy_face_never_the_os_font (criterion 2), fr48_4_lazy_face_is_requested_once (3), fr48_4_measure_and_draw_agree_across_the_load (4), fr48_4_covered_text_requests_nothing (5), fr10_lazy_asset_font_ref_round_trips (6, Kotlin side), plus fr48_4_a_released_lazy_face_is_asked_for_again and fr48_4_a_lazy_stack_family_is_read_again_when_its_face_arrives. The faces are TinyIconFont builds, so no installed font is relied on. Not compiled or run locally; they need the regenerated Protocol.gen.kt (FontRef.LazyAsset, HostEvent.AssetWanted). compose-rust/android-kotlin is restaged with stage-android-kotlin.sh.
One entry under Unreleased, after the first: lazy_asset, FontRef::LazyAsset, FontStack::lazy_family and the AssetWanted event, with what the Renderer draws before the bytes arrive.
…ock-turn-2 # Conflicts: # compose-rust/macros/tests/event_enums/fail_payload_match_without_wildcard.rs # compose-rust/macros/tests/event_enums/fail_payload_match_without_wildcard.stderr # compose-rust/src/codegen.rs # compose-rust/src/protocol.rs # compose-rust/src/schema.rs # compose-rust/tests/code_editor.rs # compose-rust/tests/color_scheme.rs # compose-rust/tests/density.rs # compose-rust/tests/fr81_native_view.rs # renderer/desktop/test/ProtocolVectorsTest.kt
# Conflicts: # compose-rust/tests/vectors/mutations.bin
HANGUL_TTOM was 0xB618, which is 똘. The full face was built for 똘 while the texts asked for 똠, so after the load no face had 똠 and it was drawn by a machine font, and the missing glyph face the test named was made for 똘. 똠 is U+B620.
… checks The event vector ends with the two rich text events and then AssetWanted's 20 bytes; one length check still stopped after the rich text events.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1057. Schema LOCK turn 2: this branch is the tip of the chain #973 → #974 → #965 → #972 → #966 → #1057 and carries the turn's one regeneration, so merge it last, after those five (its diff shows theirs until they are in).
FontRefkindLazyAsset= 4, eventAssetWanted= 71, payload 46 (asset_id: u32), as reserved.lazy_asset(AssetKind::Font, bytes)returns the idasset()would give and sets the bytes aside;FontStack::lazy_family(ids)(a stack with a lazy family is written as stack version 2; one without stays version 1 byte for byte). The Host answersAssetWantedwith the existingRegisterAsseton the next batch; an unknown id is oneProtocolError::UnknownAsset; a released face is sent again when wanted.compose-rust/tests/fr48_4_lazy_font.rs,renderer/desktop/test/LazyFontTest.kt, andfr10_lazy_asset_font_ref_round_tripson both sides.Turn gate on this head (8ba4482): codegen --no-default-features + stage, no diff; fmt; clippy --workspace --all-targets -D warnings; cargo test --workspace 1295 passed (no-default-features 869); ./kotlin test -m desktop 1443 passed; iOS simulator K/N compile; dx Android build of sample-minimal. Schema hash 0x048ae5f51d77b280, 162 properties, tables_hash 0xec93_c466_6e16_7d5e, event vector 55 records / 2062 bytes.