Tyrrrz / LightBulb

Reduces eye strain by adjusting screen gamma based on the current time
MIT License
2.23k stars 141 forks source link

Interacting with the application whitelist when a file path to an uninstalled/moved program is in the list crashes LightBulb. #293

Closed joas47 closed 3 months ago

joas47 commented 4 months ago

Version

v2.4.12

Platform

Windows 10

Steps to reproduce

Whitelist an application - Settings -> Application whitelist -> Add an application Uninstall the application just whitelisted (i guess moving the folder works too). Go into the application whitelist again and click anywhere -> LightBulb crashes.

Unable to remove applications from the whitelist.

Details

Able to interact with the whitelist

Can't when an application is removed/moved from it's initial location.

Checklist

Tyrrrz commented 4 months ago

Good catch. I think the best way to fix it is two-fold:

  1. Add a try/catch for this property so that non-existing applications don't crash LightBulb
  2. Add a filter inside get for this property to remove non-existing applications.

Even with 2., 1. is still needed to avoid potential race conditions.

ManOnSaturn commented 4 months ago

Hello! New here.

I've tried debugging this, but I keep on bumping into another issue in the whitelist page, which is a Stack Overflow crash when changing one or two options(maybe too quick?). I don't know if what I'm experiencing is connected to what this issue is about, though. It's a continuos loop of calls of OnPropertyChanged after setting the whitelist applications list content.

Using Windows 11, version 2.4.12 and dev build have the same issue.

I also find it difficult to debug. It would be nice to have a guide on how to contribute(setup the project, and maybe instructions on debugging).

Tyrrrz commented 4 months ago

Hi @ManOnSaturn

I recommend using an IDE like Visual Studio or JetBrains Rider, with the latest .NET SDK installed. They should provide breakpoint and debugging functionality pretty much out of the box.

The issue you're describing may be related to this hack: https://github.com/Tyrrrz/LightBulb/blob/0dd6505456739bea7a0ca6024c655756c3d4ac2c/LightBulb/Views/Components/Settings/ApplicationWhitelistSettingsTabView.axaml.cs#L26-L35

It's done so that the application whitelisted can be committed from the UI to the settings in one atomic action (by overwriting the whole list) rather than by adding and removing individual elements.

Also, looking back at my earlier comment:

  1. Add a try/catch for this property so that non-existing applications don't crash LightBulb

This doesn't make much sense, since Path.GetFileNameWithoutExtension(...) shouldn't throw an exception just because the file doesn't exist. Something else must be the source of the exception.

Tyrrrz commented 4 months ago

I tried reproducing this issue but couldn't do it. Can you clarify which exact action triggers the crash, @joas47? Your "steps to reproduce" worked fine for me.

ghost commented 3 months ago

Same bug on 2.5

Tyrrrz commented 3 months ago

Same bug on 2.5

See above

joas47 commented 3 months ago

I'm not sure how else to describe it honestly. I go into the application whitelist and click in the area and it crashes the program without an error message or anything. I made a gif of it, hopefully it helps: https://i.imgur.com/d4Fpg24.gif

Tyrrrz commented 3 months ago

Thanks for the gif, @joas47. I think it might be crashing for a reason other than the fact that the application has been deleted. I have been able to reproduce it, but the fix won't be in this release yet. For now, you can manually remove the application from the whitelist if you edit the Settings.json file in %appdata%/LightBulb/ (or in the app directory, if you use the portable version).