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

Dev build crashes on macOS #26

Open
FormalSnake opened this issue Jun 28, 2023 · 49 comments · May be fixed by #39
Open

Dev build crashes on macOS #26

FormalSnake opened this issue Jun 28, 2023 · 49 comments · May be fixed by #39
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@FormalSnake
Copy link

FormalSnake commented Jun 28, 2023

cargo tauri dev

Running BeforeDevCommand (yarn dev)
yarn run v1.22.19
warning ../../package.json: No license field
$ vite

VITE v4.3.9 ready in 408 ms

➜ Local: http://127.0.0.1:1420/
➜ Network: use --host to expose
Info Watching /Users/kyandesutter/development/FileExplorer/src-tauri for changes...
Compiling file-explorer v0.0.0 (/Users/kyandesutter/development/FileExplorer/src-tauri)
Finished dev [unoptimized + debuginfo] target(s) in 4.08s
thread 'main' panicked at 'called Result::unwrap() on an Err value: Error("EOF while parsing a value", line: 1, column: 0)', src/filesystem.rs:176:63
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5

Note from @conaticus for developers:
I have implemented a mechanism to stop the program from crashing if it is unable to deserialize the cache, but it leads to the program recaching every time it is re-run. Look out for a log message to see if the deserialization failed. There is also a panic on this line in the search.rs when searching on MacOS:

image

This is likely a string mismatch causing the program to fail when retrieving the volume from the cache.

@RaphGL
Copy link
Contributor

RaphGL commented Jun 29, 2023

hey, can you try deleting your cache and trying again and tell me whether it worked for you or not? There has been some changes to the cache format that would render your cache invalid. Your cache is stored in src-tauri/system_cache.json.

The cache issue should come up again as we're working on changing to a binary format.

@FormalSnake
Copy link
Author

The problem with that is the window becomes blank

@FormalSnake
Copy link
Author

and unresponsive.

@RaphGL
Copy link
Contributor

RaphGL commented Jun 29, 2023

@FormalSnake yes that's by design. the window freezes for a minute or two while caching cause we haven't implemented the loading screen and the caching is for now blocking.
wait for a lil bit and you should see the file explorer working. you can expect the long wait to be gone in the future.

@FormalSnake
Copy link
Author

I have let it run for an hour now and it still isn't done, and didn't write anything.

@RaphGL
Copy link
Contributor

RaphGL commented Jun 29, 2023

it should only take a couple minutes at best. something must be going wrong here. I'll see what we can do, I don't have a mac tho so I'll have to relying on other people's help.

@LeoCatsune LeoCatsune added bug Something isn't working help wanted Extra attention is needed labels Jun 30, 2023
@HenryRoutson
Copy link

This is likely a string mismatch causing the program to fail when retrieving the volume from the cache.

mount_pnt is actually an empty string "" on mac os, not sure why it would not be in the cache
Something about windows and unix having different file systems

@RaphGL
Copy link
Contributor

RaphGL commented Jun 30, 2023

This is likely a string mismatch causing the program to fail when retrieving the volume from the cache.

mount_pnt is actually an empty string "" on mac os, not sure why it would not be in the cache Something about windows and unix having different file systems

I'm on linux so it's definitely not a unix thing as it works for me and someone else on linux has tried it and it works as well. We're using a cross platform crate to retrieve mountpoints which are then stored in the cache. I'm not exactly sure whether this is an error on our part or if there's a bug on the crate itself.

@jokorone
Copy link

jokorone commented Jun 30, 2023

it seems to me the current code is trying to call .unwrap() on a poisened mutex when accessing state in the run_cache_interval loop.

        loop {
            interval.tick().await;

            let mut guard = match state_clone.lock() {
                Ok(state) => state,
                Err(poison_error) => poison_error.into_inner(),
            };

            save_to_cache(&mut guard);
        }

did the trick (honestly feels dirty tho 👀 ).

EDIT: tested on MacOS M1 Ventura

@FormalSnake
Copy link
Author

If this works please make a pr, I am not familiar with rust so I do not know where to put this modification.

@jokorone
Copy link

I'll look into the other issue you mentioned in the OP.

@jokorone
Copy link

@HenryRoutson at first I experienced the same, but deleting the system_cache.json and resolved the issue.

From the docs:

[...] where a mutex is considered poisoned whenever a thread panics while holding the mutex. Once a mutex is poisoned, all other threads are unable to access the data by default as it is likely tainted (some invariant is not being upheld).

@RaphGL
Copy link
Contributor

RaphGL commented Jun 30, 2023

I've tested it, it works for me as well.
I think the issue is that the code keeps triggering the recaching without checking if the previous caching routine is done or not. If the caching takes more than 30 seconds it will spawn a new routine that will try to lock the mutex and panic causing the poisoning.

@conaticus to fix this we could use a channel to decide when to restart the caching if necessary.

@HenryRoutson
Copy link

Also formal snake double check you have run yarn and installed tauri-cli,
i did just cargo run out of intuition first time and got a blank screen

cargo install tauri-cli
yarn

@FormalSnake
Copy link
Author

Where should I put the provided code snippet?

@HenryRoutson
Copy link

paste this in your terminal

cargo install tauri-cli
yarn

and then run

cargo tauri dev

@FormalSnake
Copy link
Author

I know that, but I mean where do I put this:

`` loop {
interval.tick().await;

        let mut guard = match state_clone.lock() {
            Ok(state) => state,
            Err(poison_error) => poison_error.into_inner(),
        };

        save_to_cache(&mut guard);
    }``

@HenryRoutson
Copy link

So search for interval.tick and you should find a loop in cache.rs you want to replace

@FormalSnake
Copy link
Author

I am not sure but i do not think it is working

@FormalSnake
Copy link
Author

I deleted the cache and i am running it now.

@FormalSnake
Copy link
Author

it's been running for 9 minutes and it didn't add anything to the system_cache, and it is still unresponsive

jokorone added a commit to jokorone/FileExplorer that referenced this issue Jun 30, 2023
@jokorone
Copy link

@FormalSnake how much diskspace are you using? 👀

@FormalSnake
Copy link
Author

I have a 256gb m1 mbair and I have 15.5gb left 💀

@RaphGL
Copy link
Contributor

RaphGL commented Jun 30, 2023

it's been running for 9 minutes and it didn't add anything to the system_cache, and it is still unresponsive

there's no system cache file anymore, at least not on the repo. cache now goes to the appropriate location depends on the operating system. check this to know where it goes on your system.

@FormalSnake
Copy link
Author

it did create a new json for me tho. Is there a new commit?

@jokorone
Copy link

I've tested it, it works for me as well. I think the issue is that the code keeps triggering the recaching without checking if the previous caching routine is done or not. If the caching takes more than 30 seconds it will spawn a new routine that will try to lock the mutex and panic causing the poisoning.

@conaticus to fix this we could use a channel to decide when to restart the caching if necessary.

Only reading this now.

There's no need to re-cache if another spawn is already doing just that. Accessing the poisoned mutex would create issues in the long run I suspect.

As with the example of @FormalSnake with a loaded Disk (and a fast chipset!, Imagine a movie buff with TBs and a Intel from 2012), I guess 30sec isn't enough and thus it kinda makes my PR obsolete 🥲

@FormalSnake
Copy link
Author

so is mine supposed to take a bit?

@RaphGL
Copy link
Contributor

RaphGL commented Jun 30, 2023

@FormalSnake try out

git pull origin/dev

the og dev branch has kind of gotten obliterated. I think you're running a few days old commit. Try running that command or just recloning the project (the lazy route).

@conaticus
Copy link
Owner

it did create a new json for me tho. Is there a new commit?

If you're on the latest version it should cache to your system's cache directory. If it fails to read the cache file it will print a log message in the console.

As mentioned in the edit there are some known issues with MacOS that need to be addressed. We are waiting on a mac developer familiar with Rust to assist with this.

@RaphGL's idea is a valid problem that a new issue should be created for however I am not convinced this is neccesarily the problem @FormalSnake is experiencing.

@FormalSnake please could you pull the latest version on the dev branch and let me know the following:

  • Any panics that occur
  • If there is a log message ever printed saying Failed to deserialize the cache from disk, recaching...
  • Whether there is a file named file-explorer.cache.bin in your /Users/{Your Name}/Library/Caches
  • The file size of the file-explorer.cache.bin if it exists

Thanks

@RaphGL
Copy link
Contributor

RaphGL commented Jun 30, 2023

As with the example of @FormalSnake with a loaded Disk (and a fast chipset!, Imagine a movie buff with TBs and a Intel from 2012), I guess 30sec isn't enough and thus it kinda makes my PR obsolete smiling_face_with_tear

@jokorone you still helped figuring out what the issue was tho :)
you could work on synchronizing the thread before respawning if you feel like it and report your findings

@jokorone
Copy link

What exactly is the idea with updating the cache in an interval?

Seems to me this eats up some memory? Not sure if neglectible.
A watcher would do the same thing, but only run when something actually changed.

@FormalSnake
Copy link
Author

It loaded really quickly now! It opened to a Loadin... screen and it created a bin file in my cache folder

@conaticus
Copy link
Owner

What exactly is the idea with updating the cache in an interval?

Seems to me this eats up some memory? Not sure if neglectible. A watcher would do the same thing, but only run when something actually changed.

The cache is stored on disk and this is a very big file that takes a few seconds to update. Filesystem changes actually occur in the background very frequently and this would invoke the program to write the file too often. It's not a perfect solution but a temporary one. I am about to open an issue about the 30s delay edge case.

@conaticus
Copy link
Owner

It loaded really quickly now! It opened to a Loadin... screen and it created a bin file in my cache folder

Great! Any errors or crashes? Does the searching work okay?

@FormalSnake
Copy link
Author

it sstill loading currently

@FormalSnake
Copy link
Author

I am going away currently so I will say if it loaded or not.

@conaticus
Copy link
Owner

I am going away currently so I will say if it loaded or not.

If it has taken this long then @RaphGL is correct. Sounds like it's trying to recache before finishing the first cache resulting in an infinite loop.

@FormalSnake
Copy link
Author

It is still going

@FormalSnake
Copy link
Author

I do not have any errors

@conaticus
Copy link
Owner

Even on slower systems this shouldn't take longer than 5 minutes. As mentioned it will likely be an infinite loop happening here. Thanks for your help and I apologise that this isn't working for you currently.

@FormalSnake
Copy link
Author

No need to apologize. I hope we figure it out

jokorone added a commit to jokorone/FileExplorer that referenced this issue Jun 30, 2023
@FormalSnake
Copy link
Author

After a few hours it did manage to cache!

@FormalSnake
Copy link
Author

searching is bad tho:

thread 'tokio-runtime-worker' panicked at 'called Option::unwrap() on a None value', src/search.rs:85:59
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/filesystem/cache.rs:139:49
thread 'notify-rs fsevents loop' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/filesystem/cache.rs:48:48
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: PoisonError { .. }', src/search.rs:82:34

@FormalSnake
Copy link
Author

And restarting the app makes it go back to Loading...

@RaphGL
Copy link
Contributor

RaphGL commented Jun 30, 2023

@FormalSnake if you start searching before entering a disk/volume you'll get a panic, is that what u did?

@FormalSnake
Copy link
Author

it also doesnt work inside a volume

@RaphGL
Copy link
Contributor

RaphGL commented Jun 30, 2023

We should probably wait for the upcoming work on the search stuff before checking that I think.
I think this issue can now be closed as you've already managed to build and run the program.
Please create an issue if you get this error after the search refactor/rewrite is merged.

@FormalSnake
Copy link
Author

No problem! Thanks for all the support!

@conaticus conaticus reopened this Jul 1, 2023
@conaticus
Copy link
Owner

conaticus commented Jul 1, 2023

This still needs addressing in future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants