{"action":"created","issue":{"url":"https://api.github.com/repos/RetroPie/EmulationStation/issues/418","repository_url":"https://api.github.com/repos/RetroPie/EmulationStation","labels_url":"https://api.github.com/repos/RetroPie/EmulationStation/issues/418/labels{/name}","comments_url":"https://api.github.com/repos/RetroPie/EmulationStation/issues/418/comments","events_url":"https://api.github.com/repos/RetroPie/EmulationStation/issues/418/events","html_url":"https://github.com/RetroPie/EmulationStation/pull/418","id":315125533,"number":418,"title":"[Grid 7] Dynamic image loader","user":{"login":"Koerty","id":24305945,"avatar_url":"https://avatars3.githubusercontent.com/u/24305945?v=4","gravatar_id":"","url":"https://api.github.com/users/Koerty","html_url":"https://github.com/Koerty","followers_url":"https://api.github.com/users/Koerty/followers","following_url":"https://api.github.com/users/Koerty/following{/other_user}","gists_url":"https://api.github.com/users/Koerty/gists{/gist_id}","starred_url":"https://api.github.com/users/Koerty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koerty/subscriptions","organizations_url":"https://api.github.com/users/Koerty/orgs","repos_url":"https://api.github.com/users/Koerty/repos","events_url":"https://api.github.com/users/Koerty/events{/privacy}","received_events_url":"https://api.github.com/users/Koerty/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2018-04-17T15:56:29Z","updated_at":"2018-04-26T13:09:44Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/RetroPie/EmulationStation/pulls/418","html_url":"https://github.com/RetroPie/EmulationStation/pull/418","diff_url":"https://github.com/RetroPie/EmulationStation/pull/418.diff","patch_url":"https://github.com/RetroPie/EmulationStation/pull/418.patch"},"body":"This is a pretty big task, so I created this PR before it's finished so you can take a first look and give me some feedback if you want to. It is not completely stable, as it still have some bugs or unintended behaviors (list at the end of this message), but the base mechanics are already here and working as intended.\r\n\r\nI rewrote the dynamic image loader from scratch, trying to make a simpler version than the original one, sadly, it isn't possible, you will understand why very soon.\r\n\r\n## Current behavior\r\nThe dynamic image loader aim to load just the textures displayed on the screen + 1 extra row on top and on the bottom, so the user is less likely to see the magic happening.\r\n\r\nFor this, I used 2 var : **target min range** and **target max range**, those are updated every time the grid scrolled up or down (which mean games displayed on screen changed).\r\n\r\nThis happen \"asynchronously\", so it don't freeze when loading big amount of images, only one image can be loaded and one can be unloaded by frame (call to the update functions).\r\n\r\nFor this, 2 other var are used : **current min range** and **current max range**. Once every frame, both the **current min and max range** go one step forward to **target min and max range**, loading or unloading images on their way.\r\n\r\nThis work pretty good, even if the user scroll down the grid at the highest speed, but it doesn't fit all use case. Sometimes, the range change a lot, for example when the user select a random game and have a big game collection so the current range and the next target range have no image in common.\r\n\r\nFor this I added a 2nd mod, badly named \"emergency mod\", when it happen, on the next frame all the currently loaded textures will be unloaded all at the same time, then the **current min and max range** will both be set to **target min range**. At this moment the \"emergency mod\" is exited and the dynamic image loader will get back to normal behavior, this mean, since the **current max range** is set to **target min range**, it will go back, step by step, to **target max range**, loading the images on its way.\r\n\r\n## Known bugs or unintended behaviors\r\n- When the menu is opened by pressing \"select\", all the images are reseted to default, even if they are not unloaded\r\n- When switching from one system to another, the current range isn't unloaded\r\n\r\n## Testing\r\nI left some debug print for now, as it help understanding what's going on.\r\n\r\nAlso, right now the system try to keep all the displayed images on screen loaded + 1 extra row and top and bottom, this can be changed to \"-1 extra row\" to better see what's happening, by changing : \r\nLine 331 : \r\n`nextTargetRange.min = startPos - mGridDimension.x();`\r\nto\r\n`nextTargetRange.min = startPos + mGridDimension.x();`\r\n\r\nLine 336 : \r\n`nextTargetRange.max = startPos + (mGridDimension.x() + 1) * mGridDimension.y();`\r\nto\r\n`nextTargetRange.max = startPos + (mGridDimension.x() - 1) * mGridDimension.y();`\r\n\r\n**Note that doing this may introduce some bugs, but you can better see base behavior.**"},"comment":{"url":"https://api.github.com/repos/RetroPie/EmulationStation/issues/comments/384635044","html_url":"https://github.com/RetroPie/EmulationStation/pull/418#issuecomment-384635044","issue_url":"https://api.github.com/repos/RetroPie/EmulationStation/issues/418","id":384635044,"user":{"login":"pjft","id":22025709,"avatar_url":"https://avatars3.githubusercontent.com/u/22025709?v=4","gravatar_id":"","url":"https://api.github.com/users/pjft","html_url":"https://github.com/pjft","followers_url":"https://api.github.com/users/pjft/followers","following_url":"https://api.github.com/users/pjft/following{/other_user}","gists_url":"https://api.github.com/users/pjft/gists{/gist_id}","starred_url":"https://api.github.com/users/pjft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjft/subscriptions","organizations_url":"https://api.github.com/users/pjft/orgs","repos_url":"https://api.github.com/users/pjft/repos","events_url":"https://api.github.com/users/pjft/events{/privacy}","received_events_url":"https://api.github.com/users/pjft/received_events","type":"User","site_admin":false},"created_at":"2018-04-26T13:09:44Z","updated_at":"2018-04-26T13:09:44Z","author_association":"NONE","body":"Thanks for the tests, and I do agree that these need to be tested out thoroughly.\r\n\r\nI am not sure that the TextureResource would be unloading textures that he would be reloading shortly after, unless we are not caching them somehow - or unless they are taking up more memory than the allotted VRAM.\r\n\r\nI believe that the texture memory manager does it in a last in first out logic, so unless we'd have queued so many textures already that we'd be unloading some that should be cached, I'm wondering why that'd be.\r\n\r\nIf you're developing on windows and can use a runtime debugger, you can certainly see what's the size of the loaded textures buffer, and what order they're in. Or we can create, for debugging purposes, a function to print the contents of that buffer (just the image paths, and loaded status, ordered), and we could call it before and after scrolling, to see what's happening.\r\n\r\nI'm not sure that the example of scrolling up should unload image #6 (in your example) and then reload it unless we're doing something unexpected."}}
{"actor":{"display_login":"pjft"}}