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

Bundle / package / distribute as desktop app with tauri #215

Closed
joepio opened this issue Jun 30, 2021 · 6 comments
Closed

Bundle / package / distribute as desktop app with tauri #215

joepio opened this issue Jun 30, 2021 · 6 comments

Comments

@joepio
Copy link
Member

joepio commented Jun 30, 2021

The app is currently installable as a PWA, which offers a decent UX for android, but still kind of sucks for desktops.

I want users to:

  • install using OS-native installers (.dmg for mac) with icons
  • system tray icons + native menu's
  • host their own atomic-server in one click
  • Have minimal impact on performance / memory
  • quickly open the search bar for atomic (this will be very important later on)

These things require a different way of bundling / distributing a desktop app.

Tauri

tauri (setup link) is a really interesting as a platform for distributing this app, especially if we can combine it with atomic-server in one package.

That means we can have a single .exe or .dmg file that just works, has a tray icon, and more...

@joepio joepio changed the title Bundle / package / distribute (with tauri?) Bundle / package / distribute as desktop app (with tauri?) Jun 30, 2021
@joepio
Copy link
Member Author

joepio commented Nov 19, 2021

I've toyed a bit with tauri, and it is pretty amazing.

  • The .dmg files it creates work great as installers
  • Binary for hello_world was 7MB. Expect atomic-server + atomic-data-browser to be around 20MB, which is still good.
  • There is an API to directly call rust functions. Not sure if I want to add a different API layer from HTTP, but it might help get even better performance.
  • It has a nice auto-update system
  • Supports icons, including system tray
  • Testing is possible with selenium / webdriver. Unfortunately no puppeteer, which is used in atomic.

@joepio joepio transferred this issue from atomicdata-dev/atomic-data-browser Nov 20, 2021
joepio added a commit that referenced this issue Nov 20, 2021
joepio added a commit that referenced this issue Nov 20, 2021
joepio added a commit that referenced this issue Nov 20, 2021
joepio added a commit that referenced this issue Nov 20, 2021
@joepio
Copy link
Member Author

joepio commented Nov 21, 2021

Have been using tauri for a day, and have made a lot of progress. Absolutely amazing tool.

However, I now feel kind of stuck. I'm trying to run a Rust server powered by actix from a tauri application. The problem is there are two async runtimes, and I think they might be incompatible. Every time I try to run async code, it simply does not execute.

I first tried calling my async server creator inside a tauri spawn:

  tauri::async_runtime::spawn(async {
    atomic_server_lib::serve::serve(&config_clone)
      .await
      .expect("could not start server");
  });

But std::rc::Rc<[std::boxed::Box<(dyn actix_web::data::DataFactory + 'static)>]> cannot be sent between threads safely

So I've tried using the actix runtime in tauri main.rs:

#[actix_rt::main]
async fn main() {
  actix_rt::spawn(async move {
    println!("This will not print");
  });

But now whatever is inside spawn will never even run.

Then I have one more trick up my sleeve:

  let system = actix_rt::System::new("atomic-server");
  actix_rt::spawn(async move {
    println!("I'm printing just fine")
  });
  system.run().unwrap();

Which does run, but after calling system.run(), nothing happens, as it's a blocking function that loops forever, of course. Perhaps if I could call system.run() from within the tauri runtime, things could work...

  tauri::async_runtime::spawn(async move {
    let _r = system.run();
  });

... but I can't call that function in a tauri::async_runtime::spawn block.

Is there a way to combine both async runtimes?

@joepio
Copy link
Member Author

joepio commented Nov 21, 2021

The beta version of actix will use the tokio runtime, which means that this problem should be adressable. So I've tried updating the actix deps, but it won't compile, as both tauri and actix use different linked versions of zstd:

error: failed to select a version for `zstd-sys`.
    ... required by package `zstd-safe v4.1.1+zstd.1.5.0`
    ... which satisfies dependency `zstd-safe = "=4.1.1"` of package `zstd v0.9.0+zstd.1.5.0`
    ... which satisfies dependency `zstd = "=0.9.0"` of package `tauri-codegen v1.0.0-beta.4`
    ... which satisfies dependency `tauri-codegen = "=1.0.0-beta.4"` of package `tauri-macros v1.0.0-beta.5`
    ... which satisfies dependency `tauri-macros = "=1.0.0-beta.5"` of package `tauri v1.0.0-beta.8`
    ... which satisfies dependency `tauri = "=1.0.0-beta.8"` of package `atomic-server-tauri v0.28.3 (/Users/joep/dev/github/joepio/atomic-data-rust/src-tauri)`
versions that meet the requirements `=1.6.1` are: 1.6.1+zstd.1.5.0

the package `zstd-sys` links to the native library `zstd`, but it conflicts with a previous package which links to `zstd` as well:
package `zstd-sys v1.5.0+zstd.1.4.9`
    ... which satisfies dependency `zstd-sys = "=1.5.0"` of package `zstd-safe v3.1.0+zstd.1.4.9`
    ... which satisfies dependency `zstd-safe = "=3.1.0"` of package `zstd v0.7.0+zstd.1.4.9`
    ... which satisfies dependency `zstd = "^0.7"` of package `actix-http v3.0.0-beta.12`
    ... which satisfies dependency `actix-http = "=3.0.0-beta.12"` of package `actix-files v0.6.0-beta.8`
    ... which satisfies dependency `actix-files = "=0.6.0-beta.8"` of package `atomic-server v0.28.2 (/Users/joep/dev/github/joepio/atomic-data-rust/server)`
    ... which satisfies path dependency `atomic-server` of package `atomic-server-tauri v0.28.3 (/Users/joep/dev/github/joepio/atomic-data-rust/src-tauri)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='zstd-sys' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `zstd-sys` which could resolve this conflict

@joepio
Copy link
Member Author

joepio commented Nov 21, 2021

This seems to fix the issue above: actix/actix-web@68a3acb

next step is to check back and update actix-files to include the above commit, and retry building.

@joepio joepio mentioned this issue Nov 21, 2021
joepio added a commit that referenced this issue Nov 21, 2021
@joepio joepio changed the title Bundle / package / distribute as desktop app (with tauri?) Bundle / package / distribute as desktop app with tauri Nov 21, 2021
@joepio
Copy link
Member Author

joepio commented Nov 23, 2021

Updating actix fixed compilation, but unfortunately not my initial problem of runtimes.

I've specified my problem in tauri discussion board: tauri-apps/tauri#2942

joepio added a commit that referenced this issue Nov 23, 2021
joepio added a commit that referenced this issue Nov 23, 2021
joepio added a commit that referenced this issue Nov 24, 2021
#215 icons, tray icon, menu

#215 make atomic-server also a library

#215 tauri menu refactor


#251 WIP
joepio added a commit that referenced this issue Nov 24, 2021
Upgrade actix version, it compliles

#215 WIP actix running in tauri!

#215 Fix actix routing

Improve tauri docs

Fix migration
joepio added a commit that referenced this issue Nov 24, 2021
#215 icons, tray icon, menu

#215 make atomic-server also a library

#215 tauri menu refactor


#251 WIP
joepio added a commit that referenced this issue Nov 24, 2021
Upgrade actix version, it compliles

#215 WIP actix running in tauri!

#215 Fix actix routing

Improve tauri docs

Fix migration
@joepio
Copy link
Member Author

joepio commented Nov 24, 2021

Ok, the basis is set up. Some work is left to do, but I'll open new issues for that.

@joepio joepio closed this as completed Nov 24, 2021
joepio added a commit that referenced this issue Nov 25, 2021
joepio added a commit that referenced this issue Dec 12, 2021
This reverts commit 6bb7412.
joepio added a commit that referenced this issue Dec 12, 2021
This reverts commit 6bb7412.
joepio added a commit that referenced this issue Dec 12, 2021
This reverts commit 6bb7412.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant