Repository navigation
android: Use Android's scroll physics, and let hosts register an AssetSource - #13
Merged
Merged
Conversation
…tSource Two gaps a host app hits on the `android::host` path. **Flings used iOS physics.** `AndroidPlatform` never implemented `Platform::gestures`, so GPUI fell back to `GestureTuning::default()` — whose `scroll_physics` is `UIScrollView`'s exponential decay. Every Android app built on gpui-mobile has therefore been flinging with iOS physics: the content coasts much further than the platform's own scroll views, which reads as the list not stopping where you expect. Return `ScrollPhysics::android()` instead, the AOSP `OverScroller` friction spline that already lives in `gestures.rs`. GPUI flings in logical pixels and a window's scale factor is Android's display density, so logical pixels are density-independent pixels and the constructor's nominal 160 dpi pairing is the right one. Measured on a Huawei P40 (1080x2340 @3x), same conversation and gesture script, 2.5s after release: fling 80ms iOS physics: 71 frames Android physics: 58 frames fling 300ms iOS physics: 60 frames Android physics: 41 frames Fewer frames because the spline sheds speed faster and the fling travels a shorter distance — the point of the change, not a regression. Frame pacing is unchanged (16ms intervals throughout, no dropped frames). The rest of `ViewConfiguration` (touch slop, tap timeouts) stays on GPUI's defaults; reading the real values over JNI is a separate change. **A host could not install an asset source.** `host::start` hands the launch closure a `&mut App`, which is one step too late: `Application::with_assets` consumes the builder, and the builder is created inside `on_surface_created` where the host cannot reach it. A host that renders SVGs or icons through the asset source gets empty results with no error — `AssetSource::load` returning `None` is a valid answer, so nothing logs and the icons simply do not appear. `start_with_assets` stores the configuration step in a static that `on_surface_created` consumes when it builds the `Application`, right before `run_embedded`; `start` keeps its current shape for hosts that do not need one.
tuyc
force-pushed
the
tuyc/android-host-fixes
branch
from
September 16, 2026 11:31
132ef3d to
32c3ea1
Compare
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.
Two gaps a host app hits on the
android::hostpath. Both are Android-only:everything here lives under
src/android/, whichlib.rsgates behind#[cfg(target_os = "android")], so iOS does not compile it. Verified bybuilding the crate for
aarch64-apple-ioswith these changes applied.Flings used iOS physics
AndroidPlatformnever implementedPlatform::gestures, so GPUI fell back toGestureTuning::default()— whosescroll_physicsisUIScrollView'sexponential decay. Every Android app built on gpui-mobile has therefore been
flinging with iOS physics: the content coasts much further than the platform's
own scroll views, which reads as the list not stopping where you expect.
This returns
ScrollPhysics::android()instead, the AOSPOverScrollerfriction spline that already lives in
gestures.rs. GPUI flings in logicalpixels and a window's scale factor is Android's display density, so logical
pixels are density-independent pixels and the constructor's nominal 160 dpi
pairing is the right one.
Measured on a Huawei P40 (1080x2340 @3x), same conversation and gesture script,
counting frames for 2.5s after release:
Fewer frames because the spline sheds speed faster and the fling travels a
shorter distance — the point of the change, not a regression. Frame pacing is
unchanged: 16ms intervals throughout,
droppedFrames = 0in both.The rest of
ViewConfiguration(touch slop, tap timeouts) stays on GPUI'sdefaults; reading the real values over JNI is a separate change.
A host could not install an asset source
host::starthands the launch closure a&mut App, which is one step too lateto install an asset source:
Application::with_assetsconsumes the builder, andthe builder is created inside
on_surface_createdwhere the host cannot reachit.
The failure is silent.
AssetSource::loadreturningNoneis a valid answer,so nothing logs and anything resolved through the asset source — icons, SVGs —
simply does not appear.
start_with_assetsstores the configuration step in a static thaton_surface_createdconsumes when it builds theApplication, right beforerun_embedded.startkeeps its current shape for hosts that do not need one.Testing
android::hostpath, release build: flings and scrolling asabove, no panics,
droppedFrames/lateAcquireFramesboth 0.cargo check --target aarch64-linux-androidandcargo check --target aarch64-apple-iosboth clean.