tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] on_page_load doesn't work the same on Android

Open jhutchins opened this issue 1 year ago • 2 comments

Describe the bug

It appears like the initialization javascript that invokes the __initialized message is loaded on every page load for the desktop version of an application, but for an Android version that's only load on the initial page and subsequent page loads don't. This results in any callback loaded to the on_page_load gets invoked on every page load for desktop, but only on the initial load for Android.

Reproduction

No response

Expected behavior

I would expect that the on_page_load callback be called on every page load.

Platform and versions

❯ cargo tauri info

[✔] Environment
    - OS: Mac OS 12.6.6 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.70.0 (90c541806 2023-05-31)
    ✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (environment override by RUSTUP_TOOLCHAIN)
    - node: 19.9.0
    - pnpm: 7.27.0
    - yarn: 1.22.19
    - npm: 9.6.3

[-] Packages
    - tauri [RUST]: 2.0.0-alpha.10
    - tauri-build [RUST]: no manifest (2.0.0-alpha.5, 2.0.0-alpha.6)
    - wry [RUST]: 0.28.3
    - tao [RUST]: 0.19.1
    - @tauri-apps/api [NPM]: not installed!
    - @tauri-apps/cli [NPM]: 2.0.0-alpha.9

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/

Stack trace

No response

Additional context

I wonder if loading javascript into the page to handle this is the best way of doing it. It might make more sense to leverage the navigation handler or some other native hook on the various platforms and have that trigger the callback instead. It just seems like there's a lot more control interacting directly with the web viewer than trying to inject javascript into the page.

I would potentially be willing to investigate this if core team members think it's a good direction.

jhutchins avatar Jun 18 '23 20:06 jhutchins

I agree, wry should expose a callback for page load, it seems to be possible on most platforms.

amrbashir avatar Jun 19 '23 12:06 amrbashir

I'm working on this and the initial draft of the Wry implementation is done. https://github.com/tauri-apps/wry/pull/980

jhutchins avatar Jun 25 '23 04:06 jhutchins

This should be resolved in https://github.com/tauri-apps/tauri/pull/7305

jhutchins avatar Jun 26 '23 18:06 jhutchins

Resolved in https://github.com/tauri-apps/tauri/pull/8116

amrbashir avatar Feb 14 '24 00:02 amrbashir