zidoro / pomatez

Stay Focused. Take a Break.
https://zidoro.github.io/pomatez/
MIT License
3.97k stars 165 forks source link

Framework migration/Dual Support #282

Closed TishanV closed 10 months ago

TishanV commented 2 years ago

Is your feature request related to a problem? Please describe. As I know Electron is a great framework for cross-platform apps but it's downfall is that it uses Chromium which takes lot of RAM and app bundle size. Since Pomatez app is light unlike VSCode try considering migrate to other lightweight frameworks like Tauri or Neutralino.js.

TishanV commented 2 years ago

If you are okay with it assign me to this issue.

roldanjr commented 2 years ago

If you are okay with it assign me to this issue.

Hi @TishanV , I'm good with that as long as the project will benefit from it.

What do you think @sekwah41 @gillisandrew?

sekwah41 commented 2 years ago

I'm quite open to looking into Tauri. I've actually been considering doing it for this app as a practice anyway.

As we have little to no direct desktop code other than revising and a few other things I don't believe this would be a major change and we can reuse most basically all the front-end stuff.

Only reason I've not looked before is being tied up with some other projects or my other projects would require a full redo of the code signing phase.

Only thing I think we'd need to look into is how to get Tauri apps on the snap store or automate that.

Also it would make other os specific bugs a little less friendly as e.g. Mac uses safari built in if I understand correctly.

Another part is Tauri is exploring allowing mobile apps too so we'd be able to publish an Android and iOS version in the future when the framework matures further if we so please.

sekwah41 commented 2 years ago

Only part is the backend would be in rust which shouldn't be complex anyway as from what I've seen the framework is pretty clean and makes small bundles.

And while it would be a first for me in rust I've been looking into the language quite a bit and would be more than happy to use this project as an excuse to properly try to learn it even as a concept as I was considering doing it anyway.

sekwah41 commented 2 years ago

I've also pinned this issue as it would be quite a major one that would render some of the backlog of bugs redundant.

sekwah41 commented 2 years ago

In case anyone has not seen Tauri https://github.com/tauri-apps/tauri

And an example of how they are progressing, they have an experimental snapshot ready for ios https://github.com/tauri-apps/tauri/tree/feat/ios-build

roldanjr commented 2 years ago

In case anyone has not seen Tauri https://github.com/tauri-apps/tauri

And an example of how they are progressing, they have an experimental snapshot ready for ios https://github.com/tauri-apps/tauri/tree/feat/ios-build

This is awesome, I was thinking to learn Flutter before I saw this.

sekwah41 commented 2 years ago

If you are focusing on mobile first @roldanjr you may also be interested in react-native using expo (speeds up dev and is reccomended by the react site), flutter or ionic.

Also for now snap isnt supported by tauri though I will look into how to compile it for snap and either setup some stuff or try to work on adding support to tauri depending on the complexity >.> as there are already linux builders for AppImage and deb.

If this project https://www.npmjs.com/package/tauri-snap-packager or something else I find doesn't work.

sekwah41 commented 2 years ago

Ok ive started looking into rust and honestly, I wish id tried it earlier, once I am happy enough with it ill move onto tauri and start trying a migration.

Seems like a pretty good clean language as well as some very powerful libraries e.g. tauri.

Luckily I have experience with a fair few languages that seem to structure in similar ways so its not fully jumping into the dark but when I can ill comment here with the branch I am working on in case anyone more experienced with rust would like to point me towards best practices or ways to improve :)

q-wertz commented 1 year ago

Are there any news on this? Excited to see it :)

roldanjr commented 1 year ago

Are there any news on this? Excited to see it :)

@sekwah41 is trying to work on the Backend migrating it to Tauri while on my side, I'm trying to target Mobile, Web, and Desktop for the Frontend using React Native + Web. It will take a while before we release a new version of this app especially since we are just doing it in our own spare time but it's worth the effort.

q-wertz commented 1 year ago

Thanks for the info :blush: Really like the app and the design. Take your time :)

sekwah41 commented 1 year ago

@roldanjr one thing you make like is tauri is aiming to allow iOS and android targets too.

They have some in dev branches but if u remember correctly it's getting there.

sekwah41 commented 1 year ago

https://tauri.app/v1/guides/distribution/sign-linux one issue there will be of using tauri is that it doenst have the same amount of linux targets as electron builder.

at minimum id like to support AppImage which seems possible and Snap which I will need to also investigate.

I will take a look into how close the mobile version platforms of tauri are to being ready but I may delay this until I've made changes to the frontend to support it running on Ionic on mobile devices.

sekwah41 commented 1 year ago

As long as the calls to the backend are non-implementation specific we can tinker with both at the same time even if it's just a testing branch or using it to cover the targets Tauri can atm. It's already a goal to target multiple backend systems because of the mobile goals.

sekwah41 commented 1 year ago

Actually, because @roldanjr has used the default snap building mechanism rather than the electron builder output for snap solely hes actually possibly made it a lot easier to modify this to use Tauri for the snapcraft version.

sekwah41 commented 1 year ago

Luckily it looks like you can also compile the windows binaries on on linux but itll probably be less fiddly to just compile on the correct platforms.

Just set up the base project today it seems to render fine at least. I will need to create a lost of all the features and issues that need to be implemented e.g. the fullscreen breaks or minimising to the tray.

While making these edits ill try to abstract it in some way so that the mobile version if we dont use Tauri also can hook into these same calls.

Though for the mobile version we will want flags to hide UI or alter it in ways.

sekwah41 commented 1 year ago

image The renderer obviously works fine as you can even run it in chrome. Though there is an odd flickering issue on majaro at least which seems to be a problem with webkit (see https://github.com/tauri-apps/tauri/issues/4236)

sekwah41 commented 1 year ago

Will need to update some of the postbuild scripts for stuff like the renderer to stop it from deleting files tauri wants. Also we should be copying from the other projects to here not the other way around.

sekwah41 commented 1 year ago

Some of the tools only work on Ubuntu. I'll try to take a look at adding new targets for Tauri or adding to the project itself because id like to toy with more Linux things and expand my rust knowledge so once I have some other parts out of the way or hit a wall with this ill take a tinker with more underlying parts.

One user on that issue also reported that the compiled versions locally may not have that issue but inside app images it seems to be a problem.

sekwah41 commented 1 year ago

I am temporarily disabling the main electron test build workflow while I test some tauri stuff just to avoid a lot of unneeded builds. I likely will fork it to my own one and disable it there instead tomorrow.

sekwah41 commented 1 year ago

The flickering only seems to be in dev mode when resizing so feel free to ignore that on linux at least. The AppImage ive tested that it compiles seems to be fine.

sekwah41 commented 1 year ago

So here are the tasks that still need to be done with the tauri version

As long as we can get a snap version the windows portable would be the only one we'd lose.

sekwah41 commented 1 year ago

I will check the ram usage, though image

Not only would we lose output targets we can use. The bundle size for AppImage is around about the same. Ill need to check Win and Mac but the deb files are about 6MB instead. So it can be significantly smaller.

sekwah41 commented 1 year ago

At least in appimage mode it seems to use a bit less memory as Tauri vs Electron (rough look id estimate electron uses 50% more minimum?). As the platform matures itll gain a lot more benefits, it seems we are losing a lot of key targets for linux, as well as the portable mode on windows.

sekwah41 commented 1 year ago

image The sizes are a lot better on other operating systems.

sekwah41 commented 1 year ago

I am going to go ahead with making a Tauri version while maintaining the electron version for targets it doesn't currently support.

It would also be good to look into adding feature flags or settings for hiding or setting certain settings.

sekwah41 commented 1 year ago

I will be continuing progress over here before cleaning up the commits https://github.com/sekwah41/pomatez-tauri

I've refactored the Electron context to allow a connector for us to properly talk to different platforms a bit easier.

Though I have some stuff to sort and new years plans so may not be touching this for a few days.

sekwah41 commented 1 year ago

As I'm also looking at a mobile version there is even more reason for me to progress this now.

I have some base versions with tauri already but need to finish the implementations.

I've also raised some bugs I've found on linuxnwith tauri from doing this that seem to be fixed and merged too.

Mobile news for reference https://tauri.app/blog/2022/12/09/tauri-mobile-alpha/

roldanjr commented 1 year ago

I'm actively revamping the project, making it more maintainable and scalable. But in the meantime, I will still use Electron for packaging the app for the Desktop until all our target platforms are fully supported by Tauri or we can make a gradual transition after the whole revamp has been done.

For your reference, I'm working on this branch revamp

sekwah41 commented 1 year ago

@roldanjr you may want to take a look at the renderer changes I made relating to connecting/communicating to the backend https://github.com/roldanjr/pomatez/tree/sekwah/tauri-tests/app/renderer/src/contexts

I abstracted it so we can support different platforms with the same front end.

As long as that exists and works it doesn't matter what changes you make :p it should be fine :)

roldanjr commented 1 year ago

@roldanjr you may want to take a look at the renderer changes I made relating to connecting/communicating to the backend https://github.com/roldanjr/pomatez/tree/sekwah/tauri-tests/app/renderer/src/contexts

I abstracted it so we can support different platforms with the same front end.

As long as that exists and works it doesn't matter what changes you make :p it should be fine :)

Yes, I'll consider this @sekwah41

sekwah41 commented 1 year ago

Going to give this one another push, ill organise some time to work on it, especially now that I've seen one of the apps i use called Cider has updated to use it to quite a bit of success it seems :)

sekwah41 commented 1 year ago

Relating to snap usage https://github.com/tauri-apps/tauri/pull/6532

sekwah41 commented 1 year ago

Seems that tauri is now usable on mobile and in the next major release will fully support it. Though I have a test app working locally now. Could be something fun to explore on top of the desktop app once we have that ported over.

roldanjr commented 1 year ago

That sounds cool, I'm planning to learn rust also so I will know what's happening not just on the frontend side of the app.

sekwah41 commented 11 months ago

rustrover64_F5u2OQ6Pwh Starting to get the features 1-1 with electron or possibly better in some cases, though still a fair bit more to go.

sekwah41 commented 11 months ago

You also get a few benefits from the current windows native browser

image

image

sekwah41 commented 11 months ago

While there are still pieces to implement, ill make a list in the coming days, a large portion of it at least has been sorted.

Ive uploaded this zip file as a test in case anyone wants to try, though the code is available on the sekwah/tauri-test branch too.

Would be cool to also customise the installer with some screenshots or pieces about the app

https://tauri.app/v1/api/config/#nsisconfig Pomatez_1.3.0_x64_en-US.zip

One example of a missing feature which won't be hard to add but still needs to be done is keeping the app open in the background when you click x.

So far, the bundle is 5MB.

Also, this can be made a lot smaller, though we lose a lot of debugging capabilities.

I also need to fix the selection menu for task titles.

sekwah41 commented 11 months ago

image image

You can also do this with the electron builder installer. But I thought it would be interesting to try to customise the installer a bit.

Also we can build these and run on arm. Ive seen it run on my raspberry pi fine.

sekwah41 commented 11 months ago

List of features still needed. May have missed some but these are the main ones at least

sekwah41 commented 11 months ago

The downside is the auto-updater can't be hosted purely on GitHub releases as easily. However, we could make it push to an external server.

Though I am going to leave this all for another day because I have a lot of other things to sort out today sadly :(

roldanjr commented 11 months ago

The downside is the auto-updater can't be hosted purely on GitHub releases as easily. However, we could make it push to an external server.

Though I am going to leave this all for another day because I have a lot of other things to sort out today sadly :(

That's alright @sekwah41 :) You've made a lot of effort on this, really appreciate it. Just take your time :D

sekwah41 commented 11 months ago

We may also need to take a look at possibly finding a way to get the auto updater to also look at github, though may that have issues with the electron version? Ill check this all out once I've got the rest sorted.

sekwah41 commented 11 months ago

This page will also help with info on the mobile parts https://beta.tauri.app/blog/tauri-2-0-0-alpha-4/#updating-dependencies

Here is also an upgrade guide https://beta.tauri.app/guides/upgrade-migrate/from-tauri-1/

sekwah41 commented 10 months ago

For anyone interested, I may have finished the port to Tauri aside from the auto-updater.

Test builds will be available here once its finished building

https://github.com/zidoro/pomatez/actions/runs/6619351140

So far I've only tested it on windows.

I also left out certain global hotkeys as they didn't relate to Tauri.

sekwah41 commented 10 months ago

I will take a look at how best to do the auto updater at some point, though when I can ill start doing tests on mac and linux.

sekwah41 commented 10 months ago

So by default it cant handle just pulling the files from releases like electron builder. What ill do is take a look at adding that functionality either into the base updater or our app if we can control that to a more granular level.

sekwah41 commented 10 months ago

So far, I absolutely love working with Rust. The ability to add extra functionality onto existing classes makes it really clean to make the setup tasks and avoid having to pass objects around anywhere near as much as something like node or java.

I am not sure what is considered best practice, though the modular way I am approaching this, I would like to say, is keeping the code maintainable and rather clean.

sekwah41 commented 10 months ago

Ok, generating the updater file is a bit more complex than on electron-builder. Though I could make it do separate latest files like electron builder done. I will experiment with that first but explore using a final step to upload all the assets at once and create a single combined updater file outlined in the syntax here.

image

I will once I've got past a certain point do some test releases on my own personal fork before publishing this.

However I need to switch focus onto an event for the beginning of November so I may not be able to progress this for a few weeks. Though I want to see this working as it feels so close!! :)

Another issue is that I'm having a bit of trouble getting it to properly use the keys for signing updates so need to also find why that is.