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

100% CPU consumption bug #2074

Closed
dizda opened this issue Jun 25, 2021 · 17 comments · Fixed by #2125
Closed

100% CPU consumption bug #2074

dizda opened this issue Jun 25, 2021 · 17 comments · Fixed by #2125

Comments

@dizda
Copy link
Contributor

dizda commented Jun 25, 2021

Describe the bug

When I launch the "helloworld" example, the CPU consumption goes to 100%.
The commit 3280c4a introduce the bug.

To Reproduce

git checkout 3280c4aa91e50a8ccdd561a8b48a12a4a13ea8d5
cd examples/helloworld
cargo tauri dev

Expected behavior

CPU Should be around 0% when idling.
Previous commit (f7d21a4) doesn't have this bug.

git checkout f7d21a4b864e067856018e7b1f4ba178aea46d71
cd examples/helloworld
cargo tauri dev

Screenshots

Not useful

Platform and Versions (required):

Operating System - Mac OS, version 11.4.0 X64

Node.js environment
Node.js - 16.3.0
@tauri-apps/cli - 1.0.0-beta.3
@tauri-apps/api - Not installed

Global packages
npm - 7.15.1
yarn - 1.22.10

Rust environment
rustc - 1.52.1
cargo - 1.52.0

App directory structure
/dist
/node_modules
/src-tauri

App
tauri.rs - path:"../../../core/tauri" [1.0.0-beta.1] (no lockfile)
build-type - bundle
CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'
distDir - ["../index.html"]
devPath - ["../index.html"]

@dizda
Copy link
Contributor Author

dizda commented Jun 25, 2021

I've also noticed that the mapping of commands between rust and the JS doesn't work.

@nothingismagick
Copy link
Sponsor Member

That is because you are using the old version of tauri core.

tauri.rs - path:"../../../core/tauri" [1.0.0-beta.1] (no lockfile)

Please either update the source or use the latest crate from crates.io

@nothingismagick
Copy link
Sponsor Member

Because its a bit confusing, I went and tried it, running directly on m1 mac from dev (both via yarn tauri and cargo tauri), without any problems - but you should remember a couple things:

  1. please try to use latest toolchains - i.e. what is your version of the rust tauri-cli (cargo tauri --version)
  2. try this: cargo install tauri-cli --version ^1.0.0-beta.2 / or force install from the proper folder /tooling/cli.rs
  3. or run the JS version (check out the pathing in that example's package.json

@dizda
Copy link
Contributor Author

dizda commented Jun 25, 2021

FYI, I'm also on m1 mac.

what is your version of the rust tauri-cli

❯ cargo tauri --version
cargo-tauri 1.0.0-beta.2

tauri.rs - path:"../../../core/tauri" [1.0.0-beta.1] (no lockfile)

I think this is misinterpreted, because I've cloned the tauri repo, and checked out the right tag (1.0.0-beta.2).
I had first that issue with my own project, and I wanted to make sure the error was not coming from my projected, so I've tested it out with the provided examples from tauri's, and I encountered the same issues.

@dizda
Copy link
Contributor Author

dizda commented Jun 25, 2021

tauri.rs - path:"../../../core/tauri" [1.0.0-beta.1] (no lockfile)

About that part, it's when I've checked the earliest commit to find out when it started to produce the bug.

Here is the right cargo tauri dev when I check out the latest tag "git checkout tauri-v1.0.0-beta.2" (still with the bug)

❯ RUST_LOG=debug cargo tauri info

Operating System - Mac OS, version 11.4.0 X64

Node.js environment
  Node.js - 16.3.0
  @tauri-apps/cli - 1.0.0-beta.3
  @tauri-apps/api - Not installed

Global packages
  npm - 7.15.1
  yarn - 1.22.10

Rust environment
  rustc - 1.52.1
  cargo - 1.52.0

App directory structure
/src-tauri

App
  tauri.rs - path:"../../../core/tauri" [1.0.0-beta.2] (no lockfile)
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'
  distDir - ["../index.html"]
  devPath - ["../index.html"]

@dizda
Copy link
Contributor Author

dizda commented Jun 25, 2021

active toolchain

1.52.1-aarch64-apple-darwin (overridden by '/Users/j/www/tauri/rust-toolchain')
rustc 1.52.1 (9bc8c42bb 2021-05-09)

@nothingismagick
Copy link
Sponsor Member

I am on the same rustc as a matter of fact - although we should both move to 1.53.0 :|

@dizda
Copy link
Contributor Author

dizda commented Jun 25, 2021

I've also tried with yarn tauri dev, same result.

I wonder what else could be different from your environment and mine?
Do you get normal CPU consumption?

@nothingismagick
Copy link
Sponsor Member

Care to visit our discord and we can have a chat about it? Ping denjell

@RuudBurger
Copy link

RuudBurger commented Jun 26, 2021

@nothingismagick

This is closed but I also have this issue.
Using npx create-tauri-app and picking the vanilla.js version.
If I run it cpu is at 100%.

Operating System - Mac OS, version 11.3.1 X64

Node.js environment
  Node.js - 14.17.0
  @tauri-apps/cli - 1.0.0-beta.3
  @tauri-apps/api - Not installed

Global packages
  npm - 6.14.13
  yarn - 1.22.10

Rust environment
  rustc - 1.53.0
  cargo - 1.53.0

App directory structure
/dist
/node_modules
/src-tauri

App
  tauri.rs - 1.0.0-beta.2
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - ../dist

@myWsq
Copy link

myWsq commented Jun 29, 2021

Same problem when using vue-cli-plugin-tauri

Operating System - Mac OS, version 11.4.0 X64

Node.js environment
  Node.js - 16.2.0
  @tauri-apps/cli - 1.0.0-beta.3
  @tauri-apps/api - Not installed

Global packages
  npm - 7.13.0
  yarn - 1.22.10

Rust environment
  rustc - 1.53.0
  cargo - 1.53.0

App directory structure
/node_modules
/script
/public
/src-tauri
/.git
/src

App
  tauri.rs - 1.0.0-beta.4
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - Set automatically by Vue CLI plugin
  devPath - Set automatically by Vue CLI plugin
  framework - Vue.js (Vue CLI)
  bundler - Webpack

@nothingismagick
Copy link
Sponsor Member

Hmm. You know, something I remembered is that I actually transferred the contents of my Intel mac to the M1, and I am actually still using the Intel version of rustc: x86_64-apple-darwin - I never bothered to switch over since everything was working fine.

Maybe @wusyong can help us out here, since he also has an m1

@RuudBurger
Copy link

I'm on an Intel machine though, So it doesn't seem to be related to the m1

@lemarier
Copy link
Member

lemarier commented Jun 29, 2021

I can confirm tauri api kick my cpu at 100%, and wry didn’t. (Intel)

@yamadapc
Copy link

Screen Shot 2021-06-29 at 22 04 43

iteration = handle_event_loop(
event,
event_loop,
control_flow,
EventLoopIterationContext {
callback: &callback,
webviews: webviews.lock().expect("poisoned webview collection"),
window_event_listeners: window_event_listeners.clone(),
global_shortcut_manager: global_shortcut_manager.clone(),
global_shortcut_manager_handle: global_shortcut_manager_handle.clone(),
clipboard_manager: clipboard_manager.clone(),
#[cfg(feature = "menu")]
menu_event_listeners: menu_event_listeners.clone(),
#[cfg(feature = "system-tray")]
tray_context: tray_context.clone(),
},
);

I'm not familiar with CFRunLoopObserverCreate ; there's a busy loop per event-loop tick. Quite a few different things running there. I tried changing tao to kCFRunLoopDefaultMode but it doesn't change.

@yamadapc
Copy link

yamadapc commented Jun 29, 2021

This happened after changing deps from beta.1 to beta.4

Also:

lucasfernog added a commit that referenced this issue Jun 30, 2021
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
@dizda
Copy link
Contributor Author

dizda commented Jul 1, 2021

It did fix the issue!

Thanks everyone, good job @wusyong & @lucasfernog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants