GrandTheftWalrus / RuneLite-World-Heatmap

A plugin that lets you visualize the tiles of the Old School Runescape world map that you most often visit
BSD 2-Clause "Simplified" License
5 stars 3 forks source link

Can't save heatmap as an image #2

Closed Mintaras1 closed 1 year ago

Mintaras1 commented 2 years ago

Neither manual nor automatic image saving don't save heatmap as an image. When trying to do so, nothing happens. RuneLite logs:

2022-08-07 11:52:53 [pool-3-thread-1] INFO  com.worldheatmap.WorldHeatmapPlugin - Saving 'Type A' .heatmap to disk...
2022-08-07 11:52:53 [pool-3-thread-1] INFO  com.worldheatmap.WorldHeatmapPlugin - Finished writing 'Type A' .heatmap to disk after 238 ms
...
2022-08-07 11:57:24 [pool-3-thread-1] INFO  com.worldheatmap.WorldHeatmapPlugin - Saving 'Type A' heatmap image to disk...
2022-08-07 11:57:28 [pool-3-thread-1] ERROR n.r.c.util.RunnableExceptionLogger - Uncaught exception in runnable com.worldheatmap.WorldHeatmapPlugin$$Lambda$443/0x43c1ca28@fe66c3
java.lang.OutOfMemoryError: Java heap space

It's the same with "Type A" and "Type B"

GrandTheftWalrus commented 2 years ago

Intredasting. Some questions: -How much RAM do you have? (I ask because I've only tested the plugin on a PC with lots of RAM). Other pc specs might help -When you try to write the image, is there a large spike in ram usage? -Does the file .runelite/worldheatmap/osrs_world_map.png exist?

I'm going to test it out on a laptop with less resources and see if I get the error, and review the code for memory leaks. Thanks for the bug report.

Arnuh commented 2 years ago

Saw the post in the runelite discord. I'm able to reproduce the same error 100% of the time and the cause is https://github.com/GrandTheftWalrus/RuneLite-World-Heatmap/blob/master/src/main/java/com/worldheatmap/WorldHeatmapPlugin.java#L432

Running runelite via the jagex launcher gives me a MaxMemory of 512mb with around 400mb being used. Running in intellij gives me a max of 16gb with 300-600 used. I assume my plugin setup could be the cause of the 400mb?

Running a "Type A" "Write Heatmap Image" lowers free memory by about 40mb just from loading osrs_world_map.png

Also this project is kind of a mess to look at, with the main issue being the random int arrays for x,y positions and the usage of runnables instead of lambda method references

Edit: With a bit of extra testing to see if I can get a more exact memory usage number, the code from here returns 123641856 bytes for your osrs_world_map.png loaded into memory which would be a problem with the amount you have available.

Mintaras1 commented 2 years ago

-How much RAM do you have? (I ask because I've only tested the plugin on a PC with lots of RAM). Other pc specs might help

PC Specs: CPU: Ryzen 5 1400 RAM: 16gb (2x 8gb) GPU: AMD RX 570 OS: Win10 Pro 21H2 (Build 19044,1826)

-When you try to write the image, is there a large spike in ram usage?

Ram usage stays the same, only CPU usage gets a little usage spike, but thats all.

-Does the file .runelite/worldheatmap/osrs_world_map.png exist?

Nope. File structure for me looks loke this:

.runelite/
     WorldHeatMap
          Heatmap Files
               Mintaras_TypeA.heatmap
               Mintaras_TypeB.heatmap

Running runelite via the jagex launcher gives me a MaxMemory of 512mb with around 400mb being used

I'm also using Jagex launcher to launch RuneLite, but on my other RuneLite instance (separate account), launchet not thru Jaxes launcher, it still does not save heatmap image.

GrandTheftWalrus commented 2 years ago

Saw the post in the runelite discord. I'm able to reproduce the same error 100% of the time and the cause is https://github.com/GrandTheftWalrus/RuneLite-World-Heatmap/blob/master/src/main/java/com/worldheatmap/WorldHeatmapPlugin.java#L432

Running runelite via the jagex launcher gives me a MaxMemory of 512mb with around 400mb being used. Running in intellij gives me a max of 16gb with 300-600 used. I assume my plugin setup could be the cause of the 400mb?

Running a "Type A" "Write Heatmap Image" lowers free memory by about 40mb just from loading osrs_world_map.png

Also this project is kind of a mess to look at, with the main issue being the random int arrays for x,y positions and the usage of runnables instead of lambda method references

Edit: With a bit of extra testing to see if I can get a more exact memory usage number, the code from here returns 123641856 bytes for your osrs_world_map.png loaded into memory which would be a problem with the amount you have available.

Thank you for the advice. I was unsure about whether or not my use of Runnables was correct. Also, could you perhaps clarify what you meant about the random int arrays for x,y positions?

Currently, each Heatmap object stores the 2D matrix of steps per tile in a very large 2D int array, but now that it's become apparent that memory usage is more constrained than I originally thought, I'm going to make it so that heatmap data is stored in a more efficient way (probably by use of a hashmap where the keys are coordinates and the values are the step values). I'm also going to see if there's a way to load, edit, and write the heatmap image to disk in a way that uses less memory (not sure how to do that yet, since I'm already using BufferedImages, but maybe the foremost overuse of memory is due to the aforementioned method of storing heatmaps; the two heatmaps in memory being big ass 2D arrays of 32 bit integers are probably around 32 megabytes in total)

Thanks again for your input

HeyJacob commented 1 year ago

Neither manual nor automatic image saving don't save heatmap as an image. When trying to do so, nothing happens. RuneLite logs:

2022-08-07 11:52:53 [pool-3-thread-1] INFO  com.worldheatmap.WorldHeatmapPlugin - Saving 'Type A' .heatmap to disk...
2022-08-07 11:52:53 [pool-3-thread-1] INFO  com.worldheatmap.WorldHeatmapPlugin - Finished writing 'Type A' .heatmap to disk after 238 ms
...
2022-08-07 11:57:24 [pool-3-thread-1] INFO  com.worldheatmap.WorldHeatmapPlugin - Saving 'Type A' heatmap image to disk...
2022-08-07 11:57:28 [pool-3-thread-1] ERROR n.r.c.util.RunnableExceptionLogger - Uncaught exception in runnable com.worldheatmap.WorldHeatmapPlugin$$Lambda$443/0x43c1ca28@fe66c3
java.lang.OutOfMemoryError: Java heap space

It's the same with "Type A" and "Type B"

Same issue here. I don't get an image write. It's just a .heatmap file

GrandTheftWalrus commented 1 year ago

@HeyJacob Could you please try disabling every plugin besides World Heatmap and then writing an image to see if the problem persists? I think that the problem might be that users with other memory-intensive (or simply many) plugins running might run out of available memory when the World Heatmap plugin loads/writes an image, which means that the plugin works for (perhaps) most users, but never for some. It would also be very valuable feedback if you could share the list of plugins that you have running. Thank you for your help.

(P.S. I have a new update that makes the plugin require much less memory. Before I publish the update, I have to replace a dependency disallowed by RuneLite with a homemade version which will require me doing some research on manually writing PNGs chunk-by-chunk. Once it's ready, then even users with lots of plugins should not run into heap space overflow problems such as that mentioned in this issue (if I'm right about the nature of the problem).)

Mintaras1 commented 1 year ago

Could you please try disabling every plugin besides World Heatmap and then writing an image to see if the problem persists? While running RuneLite with no plugins, it works. But not with other plugins enabled.

https://youtu.be/A2EITKNCQ6w

It would also be very valuable feedback if you could share the list of plugins that you have running.

RuneLite Enabled Plugins List (Click to expand) 1. 117 HD 2. Custom Menu Swaps 3. FPS Control 4. Green Thumb 5. Ground Markets 6. Menu Entry Swapper 7. Status Bars 8. XP Globes 9. AFK Timer 10. Account 11. Agility 12. Ammo 13. Animated Icons 14. Animation Smoothing 15. Annoyance Mute 16. Anti Drag 17. BA Minigame 18. Bank 19. Bank Screenshot 20. Bank Tag Layouts 21. Bank Tags 22. Bank XP Value 23. Banked Experience 24. Barbarian Assault 25. Barrows Brothers 26. Barrows Door Highliter 27. Bats Locator 28. Better Godwars Overlay 29. Better Teleport Menu 30. Birdhouse Overlay 31. Blast Furnace 32. Boosts Information 33. Boss Timers 34. Bot Detector 35. C Engineers: Completed 36. Camera 37. Camera Smoothing 38. Cannon 39. Cannon Highliter 40. Chambers Of Xeric 41. Chat Channels 42. Chat Commands 43. Chat Filter 44. Chat History 45. Chat Timestamps 46. Chompy Hunter 47. Clan Events 48. Clue Scroll 49. Cox Censor 50. Cox Thieving 51. Cox Timers 52. Cox Vanguards 53. Coal Bag 54. Coffin Counter 55. Combat Level 56. Corporeal Beast 57. Crab Solver 58. Crate Limiter 59. Custom Cursor 60. Customizable XP drops 61. Daily Task Indicator 62. Dance Party 63. Default World 64. Dense Runecrafting 65. Diary Requirements 66. Discord 67. Door Kicker 68. Easy Giant's Foundry 69. Effective Levels 70. Entrana 71. Equipment Inspector 72. Examine 73. Fairy Rings 74. Fight Cave Waves 75. Fish Barrel 76. Fishing 77. Fishing Notifier 78. Foodie 79. Fossil Island 80. Friend List 81. Friend Notes 82. Gauntlet Minimap 83. Gnome Restaurant 84. Grand Exchange 85. Ground Items 86. Guardians of the Rift Helper 87. Herb Farming Calculator 88. Herbi AFK 89. Herbiboar 90. HiScore 91. Hide Widhets 92. Home Enforcer 93. Hub Party Panel 94. Hunter 95. Imbued Fart 96. Imbued Heart Notifier 97. Implings 98. Improved Tears Interface 99. Info Panel 100. Instance Map 101. Interac Highlight 102. Interface Styles 103. Inventory Grid 104. Inventory Setups 105. Inventory Tags 106. Item Charages 107. Item Identification 108. Item Prices 109. Item Stats 110. JeePassXC 111. Key Remapping 112. Kingdom of Miscellania 113. Kitten Tracker 114. Kourend Libraray 115. Last Seen Online 116. Logout Timer 117. Loot Logger 118. Loot Tracker 119. MLM Upper Level Markers 120. Mage Traning Arena 121. Mahogany Homes 122. Marks of Grace Counter 123. Minimap 124. Mining 125. Monkey Business 126. More Fireworks 127. Motherlode Mine 128. Mouse Tooltips 129. Music 130. NMZ Optimal Points 131. NPC Idle Timer 132. NPC Indicators 133. Nightmare Zone 134. Not Empty 135. OSRS WIki Crowdsourcing 136. OSRS Wiki Crowdsourcing (advanced) 137. Object Markers 138. Old Control Run 139. POH Storage 140. Party 141. Pest Control 142. Pet Info 143. Ping Grapher 144. Plank Sack 145. Player Indicators 146. Player-owned House 147. Poison 148. Prayer 149. Prifddinas 150. Protect Item Notify 151. Puzzle Solver 152. Pyramid Plunder 153. Quest Helper 154. Quest List 155. Quick Prayer Preview 156. RL Tray Notifications 157. Raid Points Overlay 158. Random Events 159. Regeneration Meter 160. Report Button 161. Resource packs 162. Resting 163. Roof Removal 164. Run Energy 165. Rune Pouch 166. RuneProfile 167. RuneWatch 168. Runecraft 169. Runecrafting Tracker 170. Runecrafting Utilities 171. Runedoku Helper 172. Screen Markers 173. Screenshot 174. Shortest Path 175. Skill Calculator 176. Skills Progress Bars 177. Slayer 178. Smelting 179. Spec Regen Timer 180. Special Attack Counter 181. Specimen Cleaning 182. Spirit Tree Menu 183. Supplies Used Tracker 184. TOA modern 185. TaskJingle 186. Tears Of Guthix 187. Tempoross 188. Text to speech 189. The Guns' Gains 190. Idle Indicators 191. Time Tracking 192. Time Tracking Reminder 193. Timers 194. Tithe Farm 195. ToA Points Overlay 196. ToA Puzzle Helper 197. Tombs of Amascut 198. Unresponsive Cursor 199. Vial Smasher 200. Virtual Level Ups 201. Virtual Levels 202. Wiki 203. Wintertodt 204. Woodcutting 205. World Heatmap 206. World Hopper 207. World Map 208. XP Drop 209. XP Tracker 210. XP Updater 211. Zalcano 212. ZalcanoUtility 213. Zero Remover 214. Zoom Extender 215. grimy animation
Nick2bad4u commented 1 year ago

Im getting this same error, I click write image and nothing happens

tripplehelix commented 1 year ago

I also have this issue

GrandTheftWalrus commented 1 year ago

The error sounds more pervasive than I thought at first (sounds like it's possibly effecting every user). I've been meaning to investigate and fix it for a long time, but have been pretty biz with university stuff. Anywhomst, don't worry I will fix it some time in the next couple of months. Thank you all for the interest.

P.S. I should mention: The heatmap data itself is probably indeed being saved/kept track of for you all (despite the image saving not working). So, when I fix it, you guys should be able to see your progress if you've been running the plugin.

@Mintaras1 Also thank you for ze video and list of plugins

Nick2bad4u commented 1 year ago

P.S. I should mention: The heatmap data itself is probably indeed being saved/kept track of for you all (despite the image saving not working). So, when I fix it, you guys should be able to see your progress if you've been running the plugin.

I would say you are correct as the file is still getting updated.

Nick2bad4u commented 1 year ago

Any updates to this?

GrandTheftWalrus commented 1 year ago

@Nick2bad4u Not at the moment, sorry. Still busy with school stuff but I'm rooking forward to fixing it before too long

Nick2bad4u commented 1 year ago

@Nick2bad4u Not at the moment, sorry. Still busy with school stuff but I'm rooking forward to fixing it before too long

I did some troubleshooting. and thought it was a permissions error on the folder but that does not seem to be the case as I set permissions to wide open on the entire folder.

Not sure whether that helps or not.

ingar-eh commented 1 year ago

In the folder called Heatmap Images you can rename the username_TypeA file to end with ".png" and you will get the image. Doesn't seem to work for TypeB.

Nick2bad4u commented 1 year ago

In the folder called Heatmap Images you can rename the username_TypeA file to end with ".png" and you will get the image. Doesn't seem to work for TypeB.

I tried this and neither one works. Trying to open the PNG just gives me a corrupt file error.

image image

As far as the heatmap images folder - I dont have one at all due to it now writing anything when you try to get it to generate a heatmap

ingar-eh commented 1 year ago

In the folder called Heatmap Images you can rename the username_TypeA file to end with ".png" and you will get the image. Doesn't seem to work for TypeB.

I tried this and neither one works. Trying to open the PNG just gives me a corrupt file error.

image image

As far as the heatmap images folder - I dont have one at all due to it now writing anything when you try to get it to generate a heatmap

Make sure you're in the Heatmap Images folder and not the Heatmap Files folder. From your screenshot the name of your files are ending in ".heatmap.png" which suggests you are in the Heatmap Files folder. The files ending in ".heatmap" should be left alone as these are not images.

Nick2bad4u commented 1 year ago

In the folder called Heatmap Images you can rename the username_TypeA file to end with ".png" and you will get the image. Doesn't seem to work for TypeB.

I tried this and neither one works. Trying to open the PNG just gives me a corrupt file error.

image image

As far as the heatmap images folder - I dont have one at all due to it now writing anything when you try to get it to generate a heatmap

Make sure you're in the Heatmap Images folder and not the Heatmap Files folder. From your screenshot the name of your files are ending in ".heatmap.png" which suggests you are in the Heatmap Files folder. The files ending in ".heatmap" should be left alone as these are not images.

Correct!

The issue is the heatmap images folder doesn't exist for me. Even after clicking write image.

GrandTheftWalrus commented 1 year ago

Hello All, I have a shadow JAR aka a preview of the World Heatmap update/fix which you can test out downloading it here and then running java -jar -ea worldheatmap.jar on it in a terminal. I would recommend making a backup of your ~/.runelite/worldheatmap folder (it's in your home directory) before testing it, just in case something were to go wrong and your original .heatmap files disappeared or something (don't remove it, just make a backup copy of it somewhere)

It would be super coolio if some of you could test it out and tell me if there are still any problems. Also there are some new features. One of em is a heatmap combiner tool that can be used to combine .heatmap files that were saved under different usernames, because originally I forgot to take into account that people's usernames can change. Now, the heatmap files go by unique player ID (and the image filenames properly end with ".png")

image

Nick2bad4u commented 1 year ago

Hello All, I have a shadow JAR aka a preview of the World Heatmap update/fix which you can test out downloading it here and then running java -jar -ea worldheatmap.jar on it in a terminal. I would recommend making a backup of your ~/.runelite/worldheatmap folder (it's in your home directory) before testing it, just in case something were to go wrong and your original .heatmap files disappeared or something (don't remove it, just make a backup copy of it somewhere)

It would be super coolio if some of you could test it out and tell me if there are still any problems. Also there are some new features. One of em is a heatmap combiner tool that can be used to combine .heatmap files that were saved under different usernames, because originally I forgot to take into account that people's usernames can change. Now, the heatmap files go by unique player ID (and the image filenames properly end with ".png")

image

I will try this out tomorrow.

Nick2bad4u commented 1 year ago

So I tried it out but I cannot log in because I use jagex launcher, and the command above tries to launch runelite manually and not via jagex launcher.

Can you compile the plugin so I can add it as a plugin to my current runelite folder?

GrandTheftWalrus commented 1 year ago

So I tried it out but I cannot log in because I use jagex launcher, and the command above tries to launch runelite manually and not via jagex launcher.

Can you compile the plugin so I can add it as a plugin to my current runelite folder?

You can follow these steps and then when you do the java -jar -ea worldheatmap.jar, it'll start up with your account logged in as per the usual jagex launcher way. Thanks again for helping to make sure it's working 😎

Nick2bad4u commented 1 year ago

So I tried it out but I cannot log in because I use jagex launcher, and the command above tries to launch runelite manually and not via jagex launcher. Can you compile the plugin so I can add it as a plugin to my current runelite folder?

You can follow these steps and then when you do the java -jar -ea worldheatmap.jar, it'll start up with your account logged in as per the usual jagex launcher way. Thanks again for helping to make sure it's working 😎

Thanks.

It worked. test

GrandTheftWalrus commented 1 year ago

So I tried it out but I cannot log in because I use jagex launcher, and the command above tries to launch runelite manually and not via jagex launcher. Can you compile the plugin so I can add it as a plugin to my current runelite folder?

You can follow these steps and then when you do the java -jar -ea worldheatmap.jar, it'll start up with your account logged in as per the usual jagex launcher way. Thanks again for helping to make sure it's working 😎

Thanks.

It worked. test

Awwww yeah 😎Sweet. I'll close this issue now, since the bugs have presumably been fixed by the update. It'll probably take a week or two for the update to get through the RuneLite code review and then it'll be available on the client plugin hub

Nick2bad4u commented 1 year ago

Amy idea when this update will hit runelite?

GrandTheftWalrus commented 1 year ago

Amy idea when this update will hit runelite?

Yeaahhh I made the pull request for the update and then realize there was something I need to change (may or may not be significant) and had to cancel it. I'm on break so I'll repush it in the next week or two. Sorry about the delay boys

Nick2bad4u commented 1 year ago

Amy idea when this update will hit runelite?

Yeaahhh I made the pull request for the update and then realize there was something I need to change (may or may not be significant) and had to cancel it. I'm on break so I'll repush it in the next week or two. Sorry about the delay boys

Thanks for update!