Skip to content

Adopt the newest marker state when nothing is redrawn - #11

Merged
wf9a5m75 merged 1 commit into
developfrom
fix/marker-adopts-newest-state
Sep 12, 2026
Merged

Adopt the newest marker state when nothing is redrawn#11
wf9a5m75 merged 1 commit into
developfrom
fix/marker-adopts-newest-state

Conversation

@wf9a5m75

Copy link
Copy Markdown
Contributor

症状

タイル描画のマーカーで、recomposition のたびに作り直される MarkerStateonClick が呼ばれない。呼ばれるのは前々回のハンドラで、地図を作り直すまで直らない。

原因

自動生成される id は見た目のハッシュ(position / extra / icon / clickable / draggable / animation)で、ハンドラを含まない。だから

val markerState = MarkerState(position = position, onClick = { it.animate(MarkerAnimation.Drop) })

を recomposition のたびに作ると、「同じ id・等しい fingerprint・別インスタンス」が届く。

MarkerIngestionEngine のタイル経路はこれを unchanged と判断して何もしない。タイルキャッシュを捨てて可視タイル全部を描き直さないためで、そこは正しい。ただしエンティティが前のインスタンスを持ったままになり、タップは entity.state から配送されるので古いハンドラが呼ばれる。

非タイル経路は常に updated を通って再登録するので、元から影響なし。

直し方

描画はこれまでどおり据え置いたまま、prevEntity.state !== state のときだけエンティティの state を差し替える。renderer は呼ばず、tiledDataChanged も立てないので、タイルの再生成は起きない。

3 プラットフォームの状況

非タイル タイル
js-sdk-core 穴あり → MapConductor/js-sdk-core#3 で修正 同上
android-sdk-core 毎回更新 ✓ 本 PR で修正
ios-sdk-core 毎回更新 ✓ 毎回更新 ✓(穴なし)

確認

:android-sdk-core:compileDebugKotlin BUILD SUCCESSFUL。

同じ内容を js-sdk-core 側では回帰テストで固定してある(修正前は落ち、修正後は通る)。こちらは既存のテスト基盤に合う置き場が無かったため、テストは付けていない。

A tiled marker whose look has not changed skipped the manager — correct, since
re-registering would bust the tile cache and redraw every visible tile for a
no-op — but it also left the entity pointing at the *previous* MarkerState.
Taps are dispatched from the entity's state, so the handler that runs is the
one from the composition before last.

It matters because the generated id is a hash of the look — position, extra,
icon, clickable, draggable, animation — and does not include the handlers. A
MarkerState rebuilt on recomposition with new callbacks therefore arrives with
the same id and an equal fingerprint, and its onClick never reaches the map.

The non-tiled path was never affected: it always goes through `updated` and
re-registers. This brings the tiled path in line with it, and with
js-sdk-core, which had the same hole in both paths (MapConductor/js-sdk-core#3).
ios-sdk-core re-registers unconditionally and never had it.

Nothing is redrawn: the renderer is not called and the tile cache is not
busted. Only the state reference the entity holds changes.
@wf9a5m75
wf9a5m75 merged commit aefea47 into develop Sep 12, 2026
2 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.

1 participant