1

I'm programming a game in plain Java (no external libraries). Running the project with JRebel enabled slows the performance down and frame rate goes below 1 fps.

Is there any way to use JRebel for game development? Can I for example "run" JRebel manually after I've done some changes to the code, so that it wouldn't slow down the game, but I would still see the changes without restarting the application?

I'm using Eclipse and Java 1.6, latest JRebel. I have no prior experience with JRevel, so any help is welcome. Thanks.

Arttu
  • 983
  • 8
  • 12
  • Any normal debugging environment causes a performance hit to your running codebase, let alone JRebel. What are you attempting to accomplish by using it? Do you absolutely need to have the entire game in a running state, or can you run bits and pieces of it at once? – Makoto Dec 12 '12 at 18:52
  • I'm attempting to make it possible to change the gameplay on the fly. It would probably be more feasible to do it by putting everything in the settings file, and make a button to reload settings while the game is running? I just got a JRebel license and wanted try if I could achieve something like that with it. – Arttu Dec 12 '12 at 19:03

1 Answers1

2

This doesn't seem like a good fit for JRebel. The intent is that when you're running an application that takes a long time to redeploy, like a complex WAR, you can reload classes on the fly. How long does it take to restart your game?

Web applications are very rarely doing work when a request is not happening, so you can develop, reload, test, develop...etc. Your game is likely performing work even as you code, so JRebel is likely struggling to keep reloading classes as you type, since every frame your code needs a new class definition. That's my guess.

Thorn G
  • 12,620
  • 2
  • 44
  • 56
  • 1
    You are right, it doesn't take a lot of time to restart the game. However it can take longer to play to the specific spot or to find a place where something strange happens. Then I could just keep on playing on that problematic spot while I try to fix the code without having to restart and reproduce the situation. – Arttu Dec 12 '12 at 19:06
  • Like I said, the problem is that JRebel was designed to hot-swap code into applications which are not doing constant work. Your game loop is constantly referencing your game classes, multiple times a second. This means every time you change the file while editing and saving, JRebel has to immediately reload the affected classes. This is okay in a web application where there is an expected amount of latency, but not so much here. – Thorn G Dec 12 '12 at 19:21
  • 1
    Actually, if the application is constantly active doesn't really prevent one from using JRebel for this kind of apps. The classes are reloaded whenever a class is references from outside, i.e. a public method is called from other class. So you can pretty much have a while loop in which the gameplay is happening and if the workflow doesn't exit from the loop, then you can't really change it, unless the debugger will be able to drop the current frame. It is tricky but still possible for JRebel to provide value for the game dev. Just depends how the application is implemented – Anton Arhipov Dec 12 '12 at 22:52
  • Ok, thank you, I'm starting to understand even a bit what's going on here. Would someone be able to confirm is it possible or not to make JRebel do the check and hot swap only when being told, so it wouldn't consume that much resources all the time? – Arttu Dec 13 '12 at 07:23
  • I can't speak to the efficacy of JRebel with game development, But I have personally used it for Minecraft modding in the past. – Ryan Leach Jul 15 '20 at 15:53