Skip to content

Crash from "FastFruitTree": true in CJBCheatsMenu #260

@vjek

Description

@vjek

Describe the bug
Consistent error and crash from having "FastFruitTree": true enabled on two or more multiplayer clients.
If I disable that option on all players (server and/or clients) then the problem never happens. Once enabled, the bug/exception is thrown instantly.
My suggestion would be to add either or both of the following options;

  • a global "fast machines" slider that has a range of 0.1 seconds to 2.0 seconds, for all fast machine processing, which would be a baseline delay added into the processing time of all machines.
  • a single "Fast Fruit Tree" slider with the same temporal range.
    My current working theory is that there is some kind of race condition that is being exposed here, so optionally slowing things down slightly would likely provide the players with a self-mitigation option. Or track down the root cause, that works too, but is likely going to take considerable time & effort, given this is a SpriteBatch issue. :)

To Reproduce
Exact steps which reproduce the bug, if possible. For example:

  1. Have two or more players in a multiplayer game have "FastFruitTree": true, in config.json for CJBCheats Mod.
  2. Harvest a fruit tree continuously (just hold down right click).
  3. Watch the red text appear in the SMAPI console, hundreds of times very very quickly. (it appears to be one error per frame of fruit object drawn)
  4. All connected clients crash, and crash again on reconnect, persistently, until the server is restarted and they're "reset" , position wise, away from the offending Tree.
  5. If the server does NOT have the option enabled, it still happens with two connected clients/players who have the "FastFruitTree": true, option enabled. They both still crash, while the server does not crash, and no errors are thrown to the SMAPI console on the server.

Log file
Upload your SMAPI log to https://smapi.io/log and post a link here.
Although.. these are the relevant bits:

[SMAPI] An error occurred in the game's draw loop: NullReferenceException: Object reference not set to an instance of an object.
at StardewValley.TerrainFeatures.FruitTree.draw(SpriteBatch spriteBatch) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\Farmer\Farmer\TerrainFeatures\FruitTree.cs:line 966
at StardewValley.GameLocation.drawAboveFrontLayer(SpriteBatch b) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\Farmer\Farmer\Locations\GameLocation.cs:line 17253
at StardewValley.Game1.DrawWorld(GameTime time, RenderTarget2D target_screen) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 16045
at StardewValley.Game1._draw(GameTime gameTime, RenderTarget2D target_screen) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 15614
at StardewModdingAPI.Framework.SGame._draw(GameTime gameTime, RenderTarget2D target_screen) in /home/runner/work/SMAPI/SMAPI/src/SMAPI/Framework/SGame.cs:line 250

^^^ x 100+

...
then:

[SMAPI] The game crashed when drawing, and SMAPI was unable to recover the game.
[game] The game failed to launch: InvalidOperationException: Begin cannot be called again until End has been successfully called.
at Microsoft.Xna.Framework.Graphics.SpriteBatch.Begin(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect, Nullable`1 transformMatrix) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Graphics\SpriteBatch.cs:line 108
at StardewValley.Game1.renderScreenBuffer(RenderTarget2D target_screen) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 16536
at StardewValley.Game1.Draw(GameTime gameTime) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\Farmer\Farmer\Game1.cs:line 15416
at StardewValley.GameRunner.Draw(GameTime gameTime) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\Farmer\Farmer\LocalMultiplayer.cs:line 617
at Microsoft.Xna.Framework.Game.DoDraw(GameTime gameTime) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Game.cs:line 932
at Microsoft.Xna.Framework.Game.Tick() in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Game.cs:line 661
at Microsoft.Xna.Framework.SdlGamePlatform.RunLoop() in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Platform\SDL\SDLGamePlatform.cs:line 90
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) in D:\GitlabRunner\builds\Gq5qA5P4\1\ConcernedApe\stardewvalley\MonoGame.Desktop\MonoGame.Framework\Game.cs:line 481
at StardewModdingAPI.Framework.SCore.RunInteractively() in /home/runner/work/SMAPI/SMAPI/src/SMAPI/Framework/SCore.cs:line 313
[SMAPI] Game has ended. Press any key to exit.

Screenshots
N/A (as the clients just lock/freeze and need to be forcibly closed)
One of the best mods made for any game ever, you're awesome, keep up the good work! :D

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions