Skip to content

Conversation

@RomanKovtyukh
Copy link

@RomanKovtyukh RomanKovtyukh commented May 26, 2025

It includes sqlite configuration for windows, but only tested on Linux. Got an example from here so decided not to remove the Platform.isWindows from there.

Before this change openreads was showing the following errors at the startup if you try running it on desktop:

flutter: [🌎 Easy Localization] [DEBUG] Start
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Bad state: databaseFactory not initialized
databaseFactory is only initialized when using sqflite. When using `sqflite_common_ffi`
You must call `databaseFactory = databaseFactoryFfi;` before using global openDatabase API

#0      databaseFactory.<anonymous closure> (package:sqflite_common/src/sqflite_database_factory.dart:29:7)
#1      databaseFactory (package:sqflite_common/src/sqflite_database_factory.dart:33:6)
#2      openDatabase (package:sqflite_common/sqflite.dart:83:10)
#3      DatabaseProvider.createDatabase (package:openreads/database/database_provider.dart:29:18)
<asynchronous suspension>
#4      DatabaseController.getAllBooks (package:openreads/database/database_controler.dart:30:16)
<asynchronous suspension>
#5      BookCubit._migrateCoversFromDatabaseToStorage (package:openreads/logic/cubit/book_cubit.dart:274:27)
<asynchronous suspension>
#6      BookCubit._initLoad (package:openreads/logic/cubit/book_cubit.dart:71:7)
<asynchronous suspension>

flutter: [🌎 Easy Localization] [DEBUG] Init state

#584

@RomanKovtyukh
Copy link
Author

Checked the failures:

  • will fix the code style in a separate PR
  • the intl version was failing locally too until I built it with flutter 3.29.0. So we either need to migrate to both flutter 3.23 and newer intl version if we want to fix this or we need to fix the flutter version to 3.29.0 in CI.

@RomanKovtyukh
Copy link
Author

Hi @mateusz-bak, could you please help reviewing this and couple more PRs? Or maybe there is someone else with write permissions who could help?

@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch 2 times, most recently from a63eec2 to 6645da5 Compare June 15, 2025 21:48
@RomanKovtyukh RomanKovtyukh changed the title feat: set up sqlite on linux and windows feat: run on desktop Jun 16, 2025
@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch from 6645da5 to c68f954 Compare June 16, 2025 19:25
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change already made, please rebase

pubspec.yaml Outdated
file_picker: ^8.3.1
smooth_page_indicator: ^1.1.0
intl: ^0.19.0
intl: ^0.20.0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change already made, please rebase

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change already made, please rebase

Copy link
Owner

@mateusz-bak mateusz-bak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks for the work, looks like a good improvement.

However I don't see linux or windows directories that I suppose were created after running below command:

flutter create --platforms=linux,windows .

Also please rebase to fix conflicts on already done changes.

@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch from c68f954 to a233e5f Compare July 26, 2025 11:17
@amoinier
Copy link
Contributor

Hi! I would like give some help to merge this PR. Could you give me an update on the current status of the PR and any blockers you’re facing? Thanks in advance :)

@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch from a233e5f to 006403c Compare September 7, 2025 11:59
@RomanKovtyukh
Copy link
Author

Hi, I've rebased the changes on top of the current HEAD and added the linux platform directory.

Regarding windows platform directory and build, I didn't add it because I haven't tested it there and won't be able to.

One more thing that is missing yet is an automatic build configuration for linux. We won't be able to distribute the linux version without that.

@armand-leguillou
Copy link

Hi! Has it evolved since last month?? (I can't wait to get OpenReads on my desktop bc i don't have a smartphone anymore)

@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch from 73e8188 to a571bef Compare November 16, 2025 01:03
@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch 4 times, most recently from def18f8 to 837978c Compare November 16, 2025 02:41
@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch 2 times, most recently from c8ee660 to 9acd81a Compare November 16, 2025 02:58
@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch from 9acd81a to 8f86985 Compare November 16, 2025 03:05
@RomanKovtyukh RomanKovtyukh force-pushed the feature/linux-desktop-support branch from 8f86985 to 5f40d63 Compare November 16, 2025 03:11
@RomanKovtyukh
Copy link
Author

Hi @mateusz-bak, could you please review? The linux build had been added to the test_build.yaml and the linux directory is also in git now.

I've also made the github workflow store debug build artifacts to allow reviewers run a new version without having to build it locally.

@RomanKovtyukh
Copy link
Author

BTW folks. While we're waiting for review you can try it out using the build artifacts: https://github.com/mateusz-bak/openreads/actions/runs/19399497883

To use it:

  1. Download linux-appbundle.zip
  2. unzip it somewhere on your linux machine
  3. execute: /path/to/openreads

I did fix everything platform-specific I could fine, but I might've missed something. So let me know if it's crashing or silently ignoring you.

CC: @armand-leguillou, @amoinier, @ironhak, @GLLM

@mateusz-bak
Copy link
Owner

Great work @RomanKovtyukh I'm starting the review, I'll try to finish it by tomorrow.

_startCreatingCloudBackup(context) async {
if (!(Platform.isAndroid || Platform.isIOS)) {
BackupGeneral.showInfoSnackbar(
'Cloud backup is not implemented for ${Platform.operatingSystem} yet.',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shows "Cloud backup is not implemented for linux yet."
I think it should be "Linux"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean "linux" not being with capital "L"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's coming from the Platform package, so we'd have to capitalize it ourselves as far as I understand or submit a patch to the Platform package. Don't know which is better TBH.

Hardcoding the whole string with "Linux" would mean that if we want to run it on Windows we'll have to add a separate if statement for that which I'd like to avoid.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replied by mail, and my messages have been appended to the main thread instead of this one. I wasn't aware of that behaviour, sorry. I'm posting them here now, and removing from the main one.

Do you mean "linux" not being with capital "L"?

Yes, exactly. Sorry that I wasn't precise!

It's coming from the Platform package, so we'd have to capitalize it ourselves as far as I understand or submit a patch to the Platform package. Don't know which is better TBH.

Hardcoding the whole string with "Linux" would mean that if we want to run it on Windows we'll have to add a separate if statement for that which I'd like to avoid.

I imagine this pull request will take some days before it can be merged. So how about submitting a patch, and if it's not accepted by the time we're ready to merge, we'll capitalise ourselves? I'd definitely not hardcode it

@mbeko
Copy link

mbeko commented Nov 29, 2025

BTW folks. While we're waiting for review you can try it out using the build artifacts: https://github.com/mateusz-bak/openreads/actions/runs/19399497883

Thanks a lot for your work! 👏 Here's some feedback from a short session of looking around. Although there are some issues, it's usable to a high degree, and I'm very happy to have this awesome app available on Linux 🤩 This is just great!

Functional issues

These are issues that I think would be good to fix before releasing. Note that I'm stuck with Android version 2.9.0 so I can't check exactly if they appear only on the desktop version.

  • From the welcome pages, I tried to import a backup that I created on Android, and it said that it's not valid. When I tried it from the settings menu later, it worked
  • When the backup import didn't work on the welcome pages, I tried to import the CSV, but when I clicked on the button, no file selection dialogue opened. Also from the settings menu, it doesn't work. Actually, none of the three CSV import options shows a dialogue
  • When clicking on a tag in the book list, nothing happens. In a book entry, this shows a list of books with that tag
  • Nothing happens when clicking on the button to scan the ISBN barcode. There should be at least a message saying that this isn't available on Linux. If the functionality actually is available, but there's no active camera, the message should say that a camera is needed and must be enabled
  • When clicking on the options to create a local backup or to export to CSV, it says that these aren't implemented on Linux yet, but the icons turn into progress animations that don't stop. Then I noticed the laptop's fans started spinning, and the CPU usage went from around 0% to 60-80%. This doesn't happen for the cloud backup option
  • It's not clear to me why the local backup or CSV export wouldn't work on desktop because that doesn't seem platform-specific, and I think these would be quite important to have
  • It seems files like the book database and the cover images are put directly in the home folder. This is usually frowned upon, and the recommended practice is to follow the XDG base directory specification. These files would go to $XDG_DATA_HOME (~/.local/share by default) in my opinion. I don't know if there are more files that are created by the app. If so, they should be put in an appropriate folder, too
  • I didn't find the settings button at first because it's covered by the "Debug" indicator. I guess this won't be a problem in the final release, but when we disable the debug mode, we should check that the button is actually displayed

Possible UI improvements

These issues are related to migrating the UI of a mobile app to the desktop. In my opinion, they can wait until after the first release.

  • On the welcome screen, it's not immediately obvious how to get to the next page. I tried clicking, holding and dragging, and clicking on the left and the right side. It took me a while to realise that I have to click on the dots at the bottom. They're also pretty small and not that easy to target
  • The dark mode style option doesn't make much sense to me on the desktop. Unless maybe someone wants to run the app on a Linux phone with an AMOLED screen
  • There's much more screen estate on the desktop so the maximum configurable grid size could be greater than just four
  • Because of the additional space available, the detailed grid could display more than just the title
  • When editing a book, the text fields are very long due to a desktop screen being wide. This makes especially the content of fields with more text, like review or notes, difficult to read. I think there should be a reasonable maximum value for the width of the whole form
  • The book cover is displayed unnecessarily large when editing a book
  • In the statistics, the graph widgets are large, the bars thin and spread out, and the numbers very small. I would set a limit on the widget size, set the bar width such that the bars fill the whole widget width, and scale the font proportionally
  • The scroll bars appear only when actually scrolling, so sometimes it's not obvious that there's more content to see. It might be a good idea to show them permanently
  • The window has no icon and the title says "openreads". I think it should be "Openreads" with capital "O"
  • In the sort/filter dialogue, it's not obvious how to scroll the tag list vertically, at least not on my laptop without a mouse. It's a ThinkPad, so finally I managed by holding the button representing the middle mouse button, and moving the trackpoint left and right

@RomanKovtyukh
Copy link
Author

Thanks for the review, @mbeko. Really good findings you have there.

From the welcome pages, I tried to import a backup that I created on Android, and it said that it's not valid. When I tried it from the settings menu later, it worked

I'm kind of able to reproduce this or similar issue sometimes: openreads is saying "the file is not a valid opereads backup", but then it's working perfectly fine on subsequent runs. Debugging showed that the file is really the right backup, so we must've returned nil instead of a version from the _checkInfoFileVersion and that looks like some race condition to me.

Nothing happens when clicking on the button to scan the ISBN barcode. There should be at least a message saying that this isn't available on Linux. If the functionality actually is available, but there's no active camera, the message should say that a
camera is needed and must be enabled

Sure, need to fix it before releasing.

When clicking on the options to create a local backup or to export to CSV, it says that these aren't implemented on Linux yet, but the icons turn into progress animations that don't stop. Then I noticed the laptop's fans started spinning, and the CPU
usage went from around 0% to 60-80%. This doesn't happen for the cloud backup option

Yeah, need to fix this. I've seen it, but didn't pay attention since I didn't wait long enough to notice the CPU consumption.

It's not clear to me why the local backup or CSV export wouldn't work on desktop because that doesn't seem platform-specific, and I think these would be quite important to have

Agree

It seems files like the book database and the cover images are put directly in the home folder. This is usually frowned upon, and the recommended practice is to follow the XDG base directory specification. These files would go to $XDG_DATA_HOME (~/.
local/share by default) in my opinion. I don't know if there are more files that are created by the app. If so, they should be put in an appropriate folder, too

Good point. I need to check since I've seen files in ~/.local/ too. Would be good to have that as part settings eventually so that we can share the files with syncthing on mobile platforms.

I didn't find the settings button at first because it's covered by the "Debug" indicator. I guess this won't be a problem in the final release, but when we disable the debug mode, we should check that the button is actually displayed

Yeah, had the same trouble. On the release builds it's working well -- just no "Debug" indicator.

Still need to check the rest of the issues you mentioned. Thanks again for the review.

@RomanKovtyukh
Copy link
Author

From the welcome pages, I tried to import a backup that I created on Android, and it said that it's not valid. When I tried it from the settings menu later, it worked

I'm kind of able to reproduce this or similar issue sometimes: openreads is saying "the file is not a valid opereads backup", but then it's working perfectly fine on subsequent runs. Debugging showed that the file is really the right backup, so we must've returned nil instead of a version from the _checkInfoFileVersion and that looks like some race condition to me.

ok, this is definitely a race condition of _checkInfoFileVersion with extractArchiveToDisk: we'll need to synchronously extract /tmp/info.txt first, then run asynchronous extraction of the rest and then continue checking the info file version.

Reproduced this way:

  1. prepare a backup and clean up the system
# add a couple of heavy files to a backup
zip -9 Openreads-2025_6_16-11_7_54.backup ~/Downloads/*.pdf`
# delete the /tmp/info.txt
rm /tmp/info.txt
  1. run openreads and try restoring the backup

Added commit where I'm adding a concept of an "internal error" asking users to report what happened. It shouldn't be this rushed and shouldn't be part of this PR in my opinion, so I'd like to hear @mateusz-bak opinion on this. But anyway I'd keep the if null check in one form or another even after fixing the race condition.

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

Successfully merging this pull request may close these issues.

5 participants