Skip to content

feat(permissions)!: add a Motion device permission - #1002

Merged
decrypto21 merged 21 commits into
mainfrom
nidish/motion-permission
Oct 15, 2026
Merged

decrypto21 merged 21 commits into
mainfrom
nidish/motion-permission

Conversation

@decrypto21

@decrypto21 decrypto21 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #961

Adds Motion to the device permissions. The user decides once per product (Allow Always, Allow Once, Don't Allow), and the host answers WebKit's motion request from that decision, so iOS no longer shows its own prompt on every launch.

Products call the standard DeviceMotionEvent.requestPermission() on iOS, or requestDevicePermission("Motion") on any host. No platform-specific code.

  • Protocol: Motion is appended to HostDevicePermissionRequest, so existing SCALE indexes are unchanged.
  • Native: NativeProductExecution::authorize_device_permission resolves a capability the web view gates itself through the product's saved, one-use, or prompted decision. The iOS and Android shells expose it as authorizeDevicePermission.
  • iOS: both web view engines implement requestDeviceOrientationAndMotionPermissionFor. The Rust SPA and chat runtimes resolve it through authorizeDevicePermission(.motion); the native runtime uses the existing product permission flow. The prompt, Settings > Apps, and strings cover Motion.
  • Android: WebView delivers motion events without asking, so the host answers Motion with Allow Once and no prompt. Nothing is persisted, so no stored grant outlives a settings screen that cannot show it.

The decision is made in the WebKit delegate rather than a container gate because WebKit only consults its delegate during the product's user gesture, and a round trip to the core first would lose it.

Compatibility

  • A host built before this change cannot decode Motion and answers requestDevicePermission("Motion") with a malformed-frame error rather than granted: false. Products should treat that error as motion being unsupported. The changeset says so.
  • TrUAPIProductExecutionProtocol gains authorizeDevicePermission, so a conformer outside this repo must implement it. The release needs @parity/ios-host in its title.

Known limitation

WebKit caches the motion answer per origin in the web view's data store and has no API to clear it. Within one app launch, a product's first answer therefore applies to later requests: Allow Once lasts until the app is relaunched, and a changed decision takes effect on the next launch.

Testing

  • Rust (clippy, fmt, permission tests, a native test that counts the prompt), TS client, and iOS unit tests, including a WKWebView test that requestPermission() resolves from the host's decision.
  • iOS simulator on stash.testnet: Allow Always, Don't Allow, and Allow Once on the native runtime, and Allow Always on the Rust runtime, each followed by a relaunch. WebKit's prompt never appeared, and Allow Once prompts again after a relaunch. Re-run at 4a3aeb5 on iPhone 17, iOS 26.5.
  • Android emulator on stash.testnet (Android 15, at 4a3aeb5): motion events reach the page and follow values injected with adb emu sensor set acceleration, and requestDevicePermission("Motion") is granted without a prompt, also after a force-stop.

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Pull requests that update rust code host-ios Touches the iOS host tree host-android Touches the Android host tree labels Sep 25, 2026
@github-actions github-actions Bot added the javascript Pull requests that update javascript code label Sep 25, 2026
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

CI Status: 24 required jobs green, 21 passed and 3 skipped by path filter.

All job results
job result
android-bindings success
bundle-size success
changes success
changeset-guard success
cli-package success
codegen success
e2e skipped
explorer success
headless-install success
host-android-bindings success
host-android-detekt success
host-wasm success
ios-bindings success
ios-swift success
licenses success
playground success
provider-android-bindings skipped
release-guard success
rust success
ts-client success
ts-debugger success
ts-host success
wasm-provider success
workflow-lint skipped

Signing credentials: failure as of 2026-10-14, a release may fail

Commit 28f4620e · run log

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

iOS simulator preview

Built from 6f62619ea, stamped with it in TrUAPICommit.

gh run download 36534625128 --name simulator-preview-6f62619ea
unzip polkadot-app-*.app.zip
xcrun simctl install booted polkadot-app.app
xcrun simctl launch booted io.parity.polkadotapp.develop

Or download it in a browser, which arrives as a zip wrapping
the .app.zip, so it needs unzipping twice.

An arm64 simulator slice, so it needs an Apple Silicon Mac and does not
install on a device. Kept for 14 days, after which the link stops
resolving and a new push rebuilds it.

@decrypto21
decrypto21 marked this pull request as ready for review September 25, 2026 19:04
@decrypto21
decrypto21 requested a review from a team September 25, 2026 19:04
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

This pull request touches an app, which is not built by default. Add a label for each build you want:

  • iOS simulator build, ios-simulator-build: builds the iOS app, runs its tests and attaches a build for the iOS Simulator on a Mac.
  • iOS device build, ios-device-build: attaches a signed build that installs on a registered iPhone or iPad.
  • Android build, android-device-build: attaches an APK that installs on an Android phone or an emulator.

Each starts as soon as it is added and follows the branch from then on.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Bundle size report

Compared with main at e92f330.

Raw Gzip Brotli
truapi-host 7.89 MiB (+20 B) 5.66 MiB (+25 B) 5.39 MiB (+487 B)
truapi-provider 4.03 MiB 1.27 MiB 960.1 KiB
truapi 6.30 MiB (+241 B) 891.5 KiB (+47 B) 730.0 KiB (+24 B)
Total 18.23 MiB (+261 B) 7.81 MiB (+72 B) 7.04 MiB (+511 B)

WebAssembly modules

Raw Gzip Brotli
truapi-host/wasm/web/truapi_server_bg.wasm 2.78 MiB (+20 B) 992.4 KiB (+25 B) 747.9 KiB (+499 B, +0.1%)
truapi-host/wasm/web/truapi_verifiable_bg.wasm 4.89 MiB 4.64 MiB 4.61 MiB
truapi-provider/truapi_provider_bg.wasm 3.99 MiB 1.26 MiB 952.4 KiB
Changed files (5)
Raw Gzip Brotli
truapi/explorer/codegen/types.js 222.1 KiB (+211 B, +0.1%) 30.8 KiB (+31 B, +0.1%) 24.6 KiB (+24 B, +0.1%)
truapi-host/wasm/web/truapi_server_bg.wasm 2.78 MiB (+20 B) 992.4 KiB (+25 B) 747.9 KiB (+499 B, +0.1%)
truapi/playground/codegen/truapi-dts.js 292.0 KiB (+11 B) 50.5 KiB (+4 B) 40.6 KiB (+16 B)
truapi/generated/types.js 64.3 KiB (+10 B) 7.8 KiB (+6 B, +0.1%) 6.7 KiB (+11 B, +0.2%)
truapi/playground/codegen/services.js 101.5 KiB (+9 B) 15.5 KiB (+5 B) 13.0 KiB (+2 B)

Commit: 28f4620

# Conflicts:
#	hosts/ios/polkadot-app/Modules/Products/Chat/Rust/TrUAPIChatHandler.swift
#	rust/crates/truapi-codegen/tests/golden/wire_table.rs
# Conflicts:
#	rust/crates/truapi-codegen/tests/golden/wire_table.rs
# Conflicts:
#	rust/crates/truapi-codegen/tests/golden/wire_table.rs
# Conflicts:
#	rust/crates/truapi/src/native/runtime.rs
#	rust/crates/truapi/src/native/tests.rs
#	rust/crates/truapi/src/platform/mock.rs
#	rust/crates/truapi/src/v01/permissions.rs
Comment thread rust/crates/truapi/src/native/runtime.rs Outdated
Comment thread rust/crates/truapi/src/native/runtime.rs Outdated
@decrypto21
decrypto21 enabled auto-merge October 14, 2026 11:49
@decrypto21
decrypto21 disabled auto-merge October 14, 2026 11:51
@decrypto21 decrypto21 changed the title feat(permissions): add a Motion device permission feat(permissions)!: add a Motion device permission Oct 15, 2026
@decrypto21
decrypto21 added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit 743f0ba Oct 15, 2026
47 checks passed
@decrypto21
decrypto21 deleted the nidish/motion-permission branch October 15, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation host-android Touches the Android host tree host-ios Touches the iOS host tree javascript Pull requests that update javascript code rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Motion permission for products (iOS asks again after every launch)

3 participants