Repository navigation
Run reapplyStyle() for raster layers under the controller lock - #17
Merged
Merged
Conversation
The providers' reapplyStyle() read the manager outside the lock, and then registered what they read again. A change between renderer.onChange() and registerEntity() would be re-applied with its old source or opacity, and could be overwritten by it in the manager. react-sdk hit this (MapConductor/js-sdk-core#15). Android's renderers do not suspend in that window today, so it cannot happen yet; this closes it before one does. reapplyStyle() moves here, under the same lock as add/update/upsert/clear, and no longer registers the entities again: the handles are built from the layer id.
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.
react-sdk の MapConductor/js-sdk-core#15 と同じ修正の Android 版です。プロバイダ側の PR(android-for-maplibre / android-for-mapbox / android-for-mappls)がこれに依存するので、こちらを先にマージしてください。
不具合(いまは起きない)
android-for-maplibre / android-for-mapbox / android-for-mappls の
RasterLayerController.reapplyStyle()は、ロックの外で manager を読み、renderer.onAdd()で貼り直したあと、読んだ状態で entity を登録し直していた。add/updateの途中(renderer.onChange()の後、registerEntity()の前)にこれが入ると:clear()の途中なら、消したレイヤを戻すただし、Android ではいまのところ起きない。どのプロバイダの renderer も
onAdd/onChange/onRemoveの中で中断しない(withContextもdelayも無い)。また、すべてDispatchers.Mainで動く。そのため、この隙間に別の処理が入る余地が無い。renderer に中断点が一つでも入れば起きるので、先に塞いでおく。修正
reapplyStyle()をRasterLayerControllerに移し、add/update/upsert/clearと同じsemaphoreの中で動かすdata classなので、登録済みのものが新しいスタイルでもそのまま使えるapi/android-sdk-core.apiにreapplyStyle()を追加した確認
RasterLayerReapplyStyleTest:5 件すべて通るonChange/onRemoveの中で止めて、その間にreapplyStyle()を始めるもの 4 件(ソースの差し替え、不透明度、addによる差し替え、clear)reapplyStyle()では、5 件とも失敗する:android-sdk-core:testDebugUnitTest:292 件すべて通る:android-sdk-core:apiCheckが通る。ktlintCheckは、今回触っていないファイルの既存の指摘だけで、追加・変更した部分には指摘が無い