FreeTubeApp / FreeTube

An Open Source YouTube app for privacy
https://freetubeapp.io/
GNU Affero General Public License v3.0
13.37k stars 825 forks source link

[Bug]: TypeError: Object has been destroyed at main.js #5553

Closed iCaran closed 2 months ago

iCaran commented 2 months ago

Guidelines

Describe the bug

My PC (Ubuntu 22.04.4 LTS) crashed, which is not unusual, its an old one with a very degraded battery, so it turns off when the power goes off. This time however I was using FreeTube when my pc shut down, and since I booted it back up, FreeTube won't start at all and I get this error:

image

I have tried uninstalling and reinstalling FreeTube (v0.21.3) through Software Install, but the problem persists.

Expected Behavior

It should work just fine like every other time my machine has crashed, this time however it broke FreeTube permanently somehow. Even Reinstalling doesn't seem to work

Issue Labels

causes crash, usability issue

FreeTube Version

v0.21.3

Operating System Version

Ubuntu 22.04.4 LTS

Installation Method

.deb

Primary API used

Local API

Last Known Working FreeTube Version (If Any)

No response

Additional Information

No response

Nightly Build

absidue commented 2 months ago

During the crash FreeTube didn't have time to properly shutdown so it thinks it is still running. Close FreeTube, go to ~/.config/FreeTube and delete the file called lockfile, that should fix your problem.

iCaran commented 2 months ago

Do you mean the SingletonLock file?

image

absidue commented 2 months ago

Looks like it has a different name on Linux but yes try deleting all three singleton files (on Windows it's just one).

iCaran commented 2 months ago

I deleted the three and restared Freetube, same error, the files got created again and are labled as Link (broken) again

TheodorSmall commented 2 months ago

I found out the following: By default on Linux, FreeTube seems to create these three Singleton* files:

The fact these files persist after a crash doesn't even seem to be the issue, since their deletion has no effect. Something else seems to be broken, which causes FreeTube to crash every time, regenerating the Singleton* files.

Please also note that any reinstallation process won't delete any configuration files or user data, which in this case are located in .config/FreeTube. Assuming the issue lies in this directory and some invalid file causes the crash, there are generally two possible solutions, while in both cases you should back up the complete ~/.config/FreeTube folder, because that's where all your personal data and your settings are stored. To copy them, you can use the following command or use the GUI if you prefer: cp -r ~/.config/FreeTube ~/FreeTube-backup

TheodorSmall commented 2 months ago

While FreeTube is not running, there would be no reason for a history.db~ file to exist, maybe try renaming that (e.g. to history2.db~), in case that solves the issue, and no relevant data is lost, you can delete it.

I suppose the relevant files you might want to keep for solution 2 are the following:

However, don't rely on that and better keep a complete backup of .config/FreeTube for some time.

absidue commented 2 months ago

None of your user data is corrupted.

  1. Copy the 4 files mentioned here to a different folder: https://docs.freetubeapp.io/usage/data-location/
  2. Delete everything else in that folder
  3. Copy those 4 files back
  4. Start FreeTube it should work fine again

On Windows the "is already running" stuff happens with just one file called lockfile, however by the sounds of it in typical Linux fashion, it's a lot more complicated there, so instead of trying to figure out how all of the "is already running" stuff works on Linux, it's better to just delete everything that isn't your user data and start again from there.

absidue commented 2 months ago

I have to say I'm surprised that you never had any problems every other time that your computer crashed with FreeTube open, you definitely just got lucky the other times, because when the app doesn't shutdown properly then you should expect stuff to be broken.

iCaran commented 2 months ago

I did exactly this, i deleted the Freetube folder from .config entirely, restarted freetube, it worked, but was empty and new, so i copied back just the 4 files into the newly created Freetube directory in .config again, and guess what... Same Crash, Same Error Message AGAIN,

just the 4 db files caused this

Maybe this is reproducable, somehow if these 4 files of mine are corrupted, i can upload them, someone can delete their .config/Freetube, start the app again, then put the 4 files back and restart the app again, it should break like mine does i suppose. I did this twice now, same results

absidue commented 2 months ago

In that case I'll close this as a duplicate of the existing open issue, as the cause remains a mystery because looking at the code there is no connection between the code that produces the error and the databases.

duplicate of #4762

iCaran commented 2 months ago

Well any suggestions as to what I could do or try tho? Do i really have to save goodbye to all my saved playlists, subscriptions, and history?

TheodorSmall commented 2 months ago

You can try to only copy one of the 4 files back at a time to identify which is causing the crash. To be sure, you can remove that corrupted file to check the remaining ones as well. From there, you can continue to use the valid files, and we need to figure out how to save your user data from the corrupted ones. Be sure to do backups regularly from now on (see the settings -> data, still the settings.db needs to be copied manually).

iCaran commented 2 months ago

Sorry for the delayed reply, but I think I have identified the cause. It is profiles.db, i think in an improper shutdown, it gets corrupted.

Screenshot from 2024-08-14 01-05-12 Screenshot from 2024-08-14 01-05-22

See the weird and very long line of \00\ at the end? I deleted that line, had imported the rest 3 db files as is prior to profiles.db, so i knew the final profiles.db file was the culprit.

Once i removed that weird corruption at the end, and saved it, Freetube works normally again!