kagof / intellij-pokemon-progress

A Pokémon themed progress bar for IntelliJ IDEA.
https://plugins.jetbrains.com/plugin/15090-pokemon-progress
MIT License
192 stars 21 forks source link

Settings are not preserved after closing the IDE #40

Closed TheFreezingChicken closed 3 years ago

TheFreezingChicken commented 3 years ago

Description of the bug & expected behaviour (required)

When closing and reopening the IDE, the settings of the plugin are back to defaults.

Environment Info (required)

Steps to reproduce (optional)

Additional context or information (optional)

It seems this started happening after the last update, so I have the suspicion that the change of Java version made after my last bug report for Android Studio actually broke something (you fix something for a minority and something else breaks for everybody else, I feel guilty now 🤣). I tried it on an IDE where I didn't have the plugin installed (Rider) to rule out the possibility of "dirty config" on my side, but it's happening the same way. Android Studio gives me a silent exception of the plugin where I can see a com.intellij.diagnostic.PluginException: Cannot init component state and a com.intellij.util.xmlb.XmlSerializationException: Cannot deserialize class com.kagof.intellij.plugins.pokeprogress.configuration.PokemonProgressState, so I'm smelling a serialization type/version mismatch or similar. If it's too much of a headache to fix, feel free to revert to whatever Java version you were using before, I'll live without the plugin on Android Studio if it means fixing it for everybody else 😅

kagof commented 3 years ago

Hey @TheFreezingChicken, I have some (mostly) good news on this.

I can reproduce this exception, and I see further down in the stacktrace:

Caused by: java.lang.UnsupportedOperationException
    at com.google.common.collect.ImmutableMap.clear(ImmutableMap.java:676)

It seems like I, in my infinite wisdom, decided to make the serializable state object use an ImmutableMap. Then the deserializer is calling clear on it, which, obviously, causes some issues.

image

I made this change in September, so it is possible it has just been lurking here causing problems and you're the first/only one to notice it. 🤦 Or, it is possible that newer versions of these IDEs have changed the deserialization process and it is now calling this unsupported method. Realistically, it seems much more likely to be the former than the latter, though... But, on the bright side, either way it seems unrelated to the fix that got the plugin working on Android Studio!

Anyways, the (other) good news is that I should be able to roll this fix out quickly tonight, and it shouldn't require reverting the fix to get the plugin working on AS. Hopefully JetBrains should approve it within a couple of days or so.

Thanks again for the super thorough bug report, I really appreciate your dilligence!

kagof commented 3 years ago

Alright, this is fixed in version 1.4.1 of the plugin!

Note that version 1.4.0 will likely be coming out tomorrow; it doesn't contain the fix but was submitted to JetBrains before this bug report was opened ¯\_(ツ)_/¯

The release page https://github.com/kagof/intellij-pokemon-progress/releases/tag/1.4.1 has pokemon-progress-1.4.1-ce33a0c7.zip which is the file that was uploaded to JetBrains, in case you'd like to install it before it is officially released, but hopefully JetBrains should review the change & approve it within a couple of days.

Once again, thanks a lot for the bug report!

TheFreezingChicken commented 3 years ago

No problem, thank you for spending your time on this plugin 😄 Now that you mention not noticing it, it could be that when I used it on Webstorm before updating to 1.3.1 I was lucky enough to get only the Pokémon I selected by pure chance, since I haven't had that many progress bars show on screen, and therefore me noticing it on 1.3.1 was just a coincidence. Also, great meme 🤣

TheFreezingChicken commented 3 years ago

Hi @kagof , bad news 😭 I just updated to 1.4.1, still no settings preserved 😢 I tried both on AS and WebStorm. I also tried to manually delete the settings file and uninstall the plugin on AS, and still no luck (I haven't tried this procedure on WebStorm though). Weirdly AS doesn't give me any exception this time, so I have no other input to give about this. I'd like to add that on AS I use "Settings Repository" to sync my settings, and on WebStorm I use the JetBrains Account Sync feature (or whatever it's called). I say this because I know the path for the settings files becomes different when you use those (but the IDE itself should manage the change automatically, in fact I can confirm that the PokemonProgress.xml file gets created and uploaded in the repository correctly, so I don't know if this is actually relevant).

kagof commented 3 years ago

Hi @TheFreezingChicken, sorry for an extremely late response, been a busy couple of weeks for me.

I can confirm I'm seeing the same behaviour you are on the latest version of IntelliJ, which is somewhat confusing; when I put this patch out, I explicitly tested that persistence was working. However, testing is done on version 2019.3 of IntelliJ, since that is the oldest version that the plugin supports.

My hunch that I'm going to work on is that there is some difference between newer and older versions that is causing this to silently fail. As you said, there doesn't seem to be any error messages anywhere, so this might be a bit hairy to diagnose. I'll start looking into it soon though!

TheFreezingChicken commented 3 years ago

No need to apologize, to me it's already impressive that you're replying at all considering you're probably using your free time. Take your time, it's ok if I see one more Gen 8 or 7 Pokémon running around, I won't die 😂

kagof commented 3 years ago

Hi @TheFreezingChicken I've finally had the time to look into this! Looks like the issue came from me not really knowing how the XmlSerializer works, and doing something that I thought would be harmless but wasn't.

Anyways, a 1.4.2 release has been submitted to JetBrains pending their approval which should finally resolve :)

https://github.com/kagof/intellij-pokemon-progress/releases/tag/1.4.2 (binary is uploaded here if you want it)

Thanks again for bringing all these issues to my attention, I don't think I'd have found them without your help :)

TheFreezingChicken commented 3 years ago

@kagof I confirm everything now works like a charm, thanks for the fix 😄

kagof commented 3 years ago

Thanks again @TheFreezingChicken, glad it worked :)

Take care!