Folia support for OpenInv?
Agaloth opened this issue ยท 4 comments
https://github.com/PaperMC/Folia
Here is a summary of everything made with ChatGPT to save some time:
For plugin developers, there are a few key takeaways from the given text:
-
Folia introduces regionised multithreading, which means that plugins will require modification to function properly. Plugin developers should expect compatibility with existing plugins to be at zero.
-
Folia introduces new API additions, such as the RegionisedScheduler and EntityScheduler, which can help plugins run on the correct thread context.
-
To ensure compatibility with Folia, plugin developers must mark their plugin as compatible by placing "folia-supported: true" in the plugin.yml file. Additionally, plugins must take advantage of the RegionisedScheduler and EntityScheduler API to ensure correct behavior.
-
Plugins should not assume that they can access or modify data in other regions, as Folia regions tick in parallel and do not share data. Plugin developers should take advantage of the upcoming thread-check API to ensure correct behavior.
-
There are currently broken API, including the scoreboard API, and planned API changes, such as super aggressive thread checks, which may impact plugin development.
Overall, plugin developers should be prepared for significant changes in their plugins to ensure compatibility with Folia. They should take advantage of the new API additions and mark their plugin as compatible to ensure correct behavior. Additionally, they should be aware of the limitations and rules of Folia's regionised multithreading to avoid bugs and errors in their plugins.
Looks very cool, but also very unstable. OI requires access to the main server thread for player loading currently, and given their per-entity scheduling that sounds like an absolute nightmare.
Going to say no and close this for now. If it stabilizes and becomes feasible, maybe, but frankly I'm not sure why this level of server mod is being slapped on top of Bukkit in the first place.
For future me if this gets bumped, the meat of the information was here https://github.com/PaperMC/Folia/blob/master/PROJECT_DESCRIPTION.md
Pinning this to make it clearer that it is relevant but currently not planned.
The main problem is that due to the way it currently works, OI has to load a player who is not currently online. On servers with a main thread, this must be done on the main thread. Folia appears to delegate this entirely to the Mojang player list, which has some new form of concurrency baked in. OI needs to ensure thread safety with whatever mechanisms are introduced for this when constructing its ServerPlayer in addition to not causing memory leaks (which is very easy to do by accident, see #104). Essentially, I need to spend a not-insignificant amount of time reading through Folia's Mojang-mapped source.
Additionally, PaperLib has not updated to include any form of Folia support. This means I would be on the hook for maintaining utilities to bridge Spigot-Paper-Folia if I want to support all three platforms, which I have little to no interest in doing. https://github.com/A248/MorePaperLib exists (and I have a healthy respect for A248's abilities) so this may not be a huge hurdle.
The final major issue is that Folia is still very new. It's cool, it's flashy, but it's still very experimental. It's at a point where server internals (aka what OI deals with) may be subject to rapid and dramatic change. That means a repeat of the time investment reading the source over and over to keep up.
It is currently not worth it to me to support Folia, but I am open to it when Folia stabilizes more. In the event that Folia does stabilize, I would be willing to invest the required work into figuring it out. I would also welcome PRs adding support at that point, but I am not at this time interested in the potential support burden.
Going to be blunt: I don't think it's ever going to get to the point where I feel like it's worth me investing in. This is the sort of thing that is very easy to do in a way that looks right but is very wrong. In addition to the raw time investment required, Folia adoption isn't looking great and its issues are piling up with no triage. Doing a major research project and rewrite for a percentage of servers so marginal that it gets lumped into the catch-all category isn't really compelling. I know it sucks to hear as someone who wants to use the software, but I honestly doubt I'd make it through a fraction of the slog without burning out. This is a project I do in my spare time for fun, so when it becomes less fun I don't work on it.
If it does happen, it will be incidental to other improvements, i.e. I do want to reduce the amount of version-specific internals OI has and have a vague plan to accomplish that. I also want to move offline access to be more of a NBT reader/writer instead of loading a full internal player. Theoretically both of these should reduce or remove the major problem areas on Folia. If the bar gets low enough, I'll probably clear it, but it will be years down the line.
I guess I'll unpin this so people don't get their hopes up.
I should also note so it's documented (in case anyone tries to make a hacky fork that "works"): The way OI works may require a lot more modification under the hood. Currently OI provides a view backed by the same in-memory contents of the player's inventory, which removes the need (in a normal server) to synchronize contents to ensure that inventories are up-to-date and prevent duplications/deletions. I have no idea how Folia handles inventories opened by multiple players in different regions, but actions would have to be synced to the region owning the player (if any, see note above about constructing a ServerPlayer being a complication) to prevent duplications/item corruption/general inventory functionality breakdown by concurrent modifications of the same backing contents list from different threads.