-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fix GUIMod crash when module doesn't have a compatible game version #2486
Conversation
@HebaruSan -- I tried the provided ckan from the latest .zip you posted and.. it WORKS! Hurray! I am not sure why MiniAVC is there. I have a pretty ancient KSP install from a long time ago. All my mods I installed with CKAN, though. No manually installed mods. Here is what my mod list screen looks like: I do seem to have a MiniAVC folder with MiniAVC in there from September 2016.. Should I delete that? |
@cculianu, that's great news! Thanks for trying that out. What if you change the filter from "Installed" to "All" and type "MiniAVC" in "Filter by mod name"? Does MiniAVC show up in the list in CKAN? Maybe it was indexed a long time ago and you have metadata from back then...? |
Nope. Still not there. Here is my entire CKAN folder (sans downloads/ folder). Maybe this will help you forensically? : |
Wow, it does think you have MiniAVC installed as a full module! And the "installed_modules": {
"MiniAVC": {
"install_time": "2016-09-26T17:41:31.496489+03:00",
"source_module": {
"abstract": "This plugin will notify you when updates are available for certain mods",
"author": [
"cybutek"
],
"download": "http://ksp.cybutek.net/miniavc/MiniAVC-1.0.3.0.zip",
"download_size": 34408,
"download_hash": {
"sha1": "8B956D21495ACD0911EE4C181E049A0C664D3BB4",
"sha256": "092AAFEB0FBC8EB002366136FE3AED4F496BADD7940861A8C42028D4F2822DDA"
},
"identifier": "MiniAVC",
"ksp_version_strict": false,
"license": [
"GPL-3.0"
],
"name": "KSP AVC",
"release_status": "stable",
"resources": {
"repository": "https://github.com/CYBUTEK/KSPAddonVersionChecker",
"homepage": "http://forum.kerbalspaceprogram.com/threads/79745"
},
"version": "1.0.3.0",
"spec_version": "1"
},
"installed_files": {
"GameData/MiniAVC": {},
"GameData/MiniAVC/MiniAVC.dll": {
"sha1_sum": "F6-5D-DB-C2-41-CF-AE-83-3D-CC-39-F2-EA-FC-E3-EE-51-B1-EE-2F"
}
}
}, It should be possible to find this in the metadata repositories, I'll take another look... |
OK, KSP-CKAN/NetKAN#1455 has the background info. There was an effort to support MiniAVC as a standalone mod so other mods could recommend it and users could choose whether to install it. But the architecture of MiniAVC doesn't work well for this: it checks the versions of mods in its DLL's folder and subfolders, so if we put the DLL in its own folder it won't check anything, but if we put it in GameData it will check too much. (RoverDude also thought that de-bundling MiniAVC was too much interference with mod authors' wishes.) KSP-CKAN/CKAN-meta#561 added a .ckan file as a stopgap while they worked on how a .netkan would work. Here's the bot updating it somehow: KSP-CKAN/CKAN-meta@f26d34f A year later KSP-CKAN/NetKAN#3934 removed the filtering out of bundled copies of MiniAVC. Then a year after that the .ckan file was deleted: KSP-CKAN/CKAN-meta@6cd6294 Long story short, the symptom we're looking for is: Install a mod, then it gets de-indexed. |
I'm actually a computer programmer by trade. I am not familiar enough with NetKAN or any of what even MiniAVC does (version control/checker?). I understood about 95% of that. But one question remains: Should I delete that MiniAVC? What happens when a module is ancient? Does it still get loaded? Will it do Bad Things? :) I'm really glad I was able to help you fix this and that you fixed it so fast! It's possible other people in the wild that have been using KSP since the early days (and CKAN) somehow ended up with this bug and/or in this situation. So in my mind I think it's awesome you fixed it. I did nothing outside the ordinary except use CKAN to install mods (apparently including MiniAVC)... so.. there ya go. Now.. should I delete MiniAVC from GameData/? |
Indeed, thanks for your help! At this point I would not delete it manually. You would end up with an installed module entry in your registry pointing to files that no longer exist, which may cause errors. The ideal endgame is that you would uninstall it from within CKAN itself, which would then update all the tracking data structures properly. But you can't do that currently because it doesn't show up in the mod list, so that's the next thing I plan to investigate. |
Ok, well.. until then. MiniAVC that hopefully does no evil will continue to live, like a virus, in my GameData folder. Do let me know if I can help any further, ha ha. Pretty awesome how fast you fixed it. Great project. I know C# well too.. maybe someday when my plate is freer I can also contribute to this project (although sometimes too many cooks spoil the pot). Really good useful software, this CKAN. Thumbs up on all counts. 👍 |
Note that CKAN is perfectly happy if you DELETE files. When it updates or deletes, it is fine with files being missing. |
Update, it's hiding MiniAVC because Lines 324 to 340 in 37c8477
... and the old MiniAVC module's So GUI thinks MiniAVC is already in the list when it's not. This should be identifier-based instead. This could be causing assorted other problems if there are other cases of mods inappropriately sharing the same name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am on the reviewers for this despite my not being familiar with this codebase.
Using general programmer mojo heuristics I say this appears correct, assuming identifier is unique for a module across all versions and not a hash value or something version dependent.
So.. I’m hitting approve here. (Not qualified really to do otherwise, ha).
I'm guessing LGG requested your review to confirm that the test build was working (good idea). Or I somehow misclicked it and don't remember. Either way, thanks! |
Hmm. Should I try building it and seeing if old defunct mini avc shows up now? Or did your other change make it not appear despite this change? (Actually if you can post a .zip again that’s easier as I’m not set up to build on this Mac and booting up windows for this is slightly painful as my windows system needs updates and is crufty) |
Sure, here's a new test build:
You should see a new row labeled "KSP AVC" (due to the shared name problem mentioned above), and unchecking its checkbox should allow you to uninstall. After that, the standard release of CKAN v1.25.2 should be able to start without the error. |
Great work, @HebaruSan ! |
Indeed! I've been running the demo build you sent me for weeks now without a single issue. I'm super happy!! |
Problems
As of #2437, if you have an installed module that has since been completely de-indexed (e.g., MiniAVC: KSP-CKAN/CKAN-meta#561, KSP-CKAN/CKAN-meta@6cd6294), this exception happens at GUI startup:
Unrelatedly, if you had the old standalone MiniAVC module installed, it was not shown in the mod list.
Causes
This happens when one of your installed modules is totally de-indexed. I only understood this after @cculianu shared his
registry.json
, so this PR's description previously said the cause was unknown:The crash happens here; since MiniAVC isn't in the registry, the
LatestCompatibleKSP
call returns null, and shortly after that the code attempts to access properties of that null reference:CKAN/GUI/GUIMod.cs
Lines 152 to 154 in ab714c2
Changes
GUIMod
's constructor toKspVersion.ToYalovString
. This eliminates the possibility of the version object being null inside the function. Instead, null is now checked before the function is called, and we fall back to a version string of "Unknown" in that case. It also allows us to use this logic in other places as well as test it (not included in this PR).VersionsMax
dictionary is now static and only generated once rather than being redundantly re-generated for every module.VersionMaxWasGenerated
is removed and the generation code it governed is moved to a static constructor which accomplishes the same thing more reliably with less overhead.GUIMod
's comparison operations now check theIdentifier
rather than theName
. This allows the old MiniAVC module to appear in the mod list, where it previously was hidden because itsName
was the same as KSP-AVC's.Fixes #2481.