Skip to content

Fix unnecessary map data saves (#12295) #12296

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

Merged
merged 1 commit into from
Apr 30, 2025

Conversation

Dqu1J
Copy link
Contributor

@Dqu1J Dqu1J commented Mar 14, 2025

Fixes #12295

Currently, MapCanvas API unnecessarily causes map data file to save.

The API calls this.mapView.worldMap.setColorsDirty() to mark colors dirty for players, however this has the side-effect of saving the map .dat files as well:

public void setColorsDirty(int x, int z) {
    this.setDirty(); // This saves the data file! 

    for (MapItemSavedData.HoldingPlayer holdingPlayer : this.carriedBy) {
        holdingPlayer.markColorsDirty(x, z); // This is what the API wants to do!
    }
}

This causes unnecessary lag during world saves, which scales with the amount of maps handled with API since last save. On servers that heavily rely on imageonmap-like plugins, it can cause lag spikes of dozens of seconds.

This PR changes this method to add a boolean argument to the method that determines whether the file is saved or not, which is used by the API. An overload is added for compatibility, and for vanilla.

@Dqu1J Dqu1J requested a review from a team as a code owner March 14, 2025 13:15
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Mar 14, 2025
@github-project-automation github-project-automation bot moved this from Awaiting review to Awaiting final testing in Paper PR Queue Mar 16, 2025
@Owen1212055 Owen1212055 force-pushed the fix-unnecessary-map-data-saves branch from be8b9cb to 02fc023 Compare April 29, 2025 05:37
@Owen1212055 Owen1212055 merged commit 646b80c into PaperMC:main Apr 30, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this from Awaiting final testing to Merged in Paper PR Queue Apr 30, 2025
@Dqu1J
Copy link
Contributor Author

Dqu1J commented May 1, 2025

🎉

@Dqu1J Dqu1J deleted the fix-unnecessary-map-data-saves branch May 1, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

MapCanvas#drawImage unnecessarily causes map data file to save
6 participants