Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] inner_size giving incorrect dimensions on window creation #12024

Open
vr7bd opened this issue Dec 21, 2024 · 0 comments
Open

[bug] inner_size giving incorrect dimensions on window creation #12024

vr7bd opened this issue Dec 21, 2024 · 0 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@vr7bd
Copy link

vr7bd commented Dec 21, 2024

Describe the bug

I'm trying to create a new window from rust and embed a GStreamer sink into it. However, to do so, I need the dimensions of the window to embed the surface. The window is opening in fullscreen (1920 x 1800). I'm trying to use the inner_size method and I'm not getting the correct dimensions i.e width: 852, height: 652 even though my monitor's dimensions are 1920 x 1080

static APP_HANDLE: OnceCell<Mutex<AppHandle>> = OnceCell::const_new();

#[tauri::command]
async fn initialize() -> Result<(), Error> {
    // some other stuff happening here
          let webview_window = WebviewWindowBuilder::new(
          app_handle.app_handle(),
          "overlay",
          WebviewUrl::External(Url::parse("https://example.com").unwrap()),
      )
      .decorations(false)
      .shadow(false)
      .fullscreen(true)
      .minimizable(false)
      .closable(false)
      .skip_taskbar(true)
      .transparent(true)
      .focused(false)
      .build()
      .expect("Failed to create overlay window");

       if let Some(overlay) = app_handle.get_webview_window("overlay") {
          // giving incorrect dimensions
          let size = overlay.inner_size();
          println!("SIZE {:?}", size);
      }
      let inner_size = webview_window.inner_size().unwrap();
      let inner_position = webview_window.inner_position().unwrap();
       // giving incorrect dimensions
      println!("{:?}, {:?}", inner_size, inner_position);


}

pub fn run() {
    let app = tauri::Builder::default()
        .plugin(tauri_plugin_http::init())
        .plugin(tauri_plugin_shell::init())
        .invoke_handler(tauri::generate_handler![greet, get_pin, socket_initialize,])
        .build(tauri::generate_context!())
        .expect("error while building");
    let app_handle = app.handle().clone();
    let cloned_app_handle = app.handle().clone();
    APP_HANDLE
        .set(Mutex::new(app_handle))
        .expect("Could not set static variable");
    tauri::async_runtime::spawn(async move {
        let mut interval = tokio::time::interval(Duration::from_secs(2));
        loop {
            interval.tick().await;
            if let Some(overlay) = cloned_app_handle.get_webview_window("overlay") {
                let size = overlay.inner_size();
                // giving correct dimensions 1920 x 1080
                println!("SIZE: {:?}", size);
            }
        }
    });
    app.run(|_, _| {});
}

Reproduction

No response

Expected behavior

Expecting inner_size() to give me correct dimensions of 1920 x 1080

Full tauri info output

✔] Environment
    - OS: Fedora 41.0.0 x86_64 (X64)
    ✔ webkit2gtk-4.1: 2.46.4
    ✔ rsvg2: 2.59.2
    ✔ rustc: 1.83.0 (90b35a623 2024-11-26)
    ✔ cargo: 1.83.0 (5ffbef321 2024-10-29)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 22.12.0
    - pnpm: 9.15.1
    - npm: 10.9.0

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.2
    - tao 🦀: 0.30.8
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-http 🦀: 2.2.0
    - @tauri-apps/plugin-http : 2.0.0 (outdated, latest: 2.2.0)
    - tauri-plugin-shell 🦀: 2.2.0
    - @tauri-apps/plugin-shell : 2.0.0 (outdated, latest: 2.2.0)
    - tauri-plugin-fs 🦀: 2.2.0
    - @tauri-apps/plugin-fs : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Stack trace

No response

Additional context

I'm seeing that the dimensions that I'm getting correct after the first restart. But doing a run after that is giving me the incorrect dimensions

@vr7bd vr7bd added status: needs triage This issue needs to triage, applied to new issues type: bug labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

1 participant