Improve Interop Html Elements performance by avoiding wasm2js#3003
Open
ApoloApps wants to merge 3 commits intoJetBrains:jb-mainfrom
Open
Improve Interop Html Elements performance by avoiding wasm2js#3003ApoloApps wants to merge 3 commits intoJetBrains:jb-mainfrom
ApoloApps wants to merge 3 commits intoJetBrains:jb-mainfrom
Conversation
… Added optimizations for the boundary too, like packing.
… (e: file:///home/runner/work/compose-multiplatform-core/compose-multiplatform-core/compose/ui/ui/src/webMain/kotlin/androidx/compose/ui/viewinterop/WebInteropElementHolder.web.kt:209:1 Missing return statement.)
ApoloApps
commented
Apr 23, 2026
| if (posChng) { | ||
| const left = nwPosX / dens; | ||
| const top = nwPosY / dens; | ||
| wrpEl.style.transform = "matrix(1, 0, 0, 1, " + left + ", " + top + ")"; |
Author
There was a problem hiding this comment.
This does not cause layout reflow so it is much more performant. (gonna use it in another future a11y PR I'll be submitting too)
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.
Improves performance of HtmlInteropElements by avoiding the wasm2js boundary as much as possible (since operations done are already costly on js side so we don't want to add more overhead than needed). Since some border functions were called in a place where the logic could be done in js, I've migrated it to a single js with optimizations like boolean packing for less boundary overhead
Fixes https://youtrack.jetbrains.com/issue/CMP-9757/Web-InteropElements-amount-for-a-lot-of-the-frame-time-cost
Before (check issue for more examples too, consistent 6-10ms with small 3ms and big as 15ms)





After (consistent 0.4ms to 1.8 ms with small peaks with 2-3ms and as low as a few microseconds. It maintains constant time pretty well)






Testing
Manually tested
Release Notes
N/A