-
Notifications
You must be signed in to change notification settings - Fork 415
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
Improve WebUI settings #2243
Improve WebUI settings #2243
Conversation
I just fixed an issue with the WebUISettings not loading properly on the first load. It sends an empty JSON string the first time settings load. The loading routine was expecting a value for "webui.lang" inside the JSON string. I had to add a null check. |
What about compatibility with this ? |
I fixed setting of the webui lang in the last commit. I also resolved anther regression with trying to configure the webui multiple times. This was firing |
Fixes regression with PR #2243. The 'theWebUI.config' no longer takes the 'data' argument. We use the 'this' keyword to call the stored base function from current execution context. We do not call it from the global theWebUI object. These steps prevent memory leaks in the web browser.
This pull request greatly improves the process of loading and saving WebUI settings. I originally created PR #2239, but decided to rethink how to implement this improvement. There are no race conditions here and it doesn't fix anything that is not broken.
List of Changes:
In
rtorrent.js
thegetsettings.php
AJAX request is changed from a POST method to GET method. We are getting data from the server not sending data. Flagging the method as POST is not the correct way of completing this request.The WebUI now sends an asynchronous request to retrieve the UI settings that are stored on the web server. This reduces the TBT (Total Blocking Time) of the main thread before it's time to finish initializing the WebUI. The WebUI will not finish initializing until this task has completed, to ensure there's no untended side effects with saved settings or initializing plugins.
theWebUI.config()
no longer contains the data from thegetsettings.php
AJAX request as a function parameter. None of the default ruTorrent plugins currently require this information. No third party plugins will require this information ether. A duplicate copy is stored intheWebUI.settings
array. All of the default plugins have been updated to reflect this change.It is very important to implement this change because it prevents the possibly of a memory of a leak being created. It also prevents plugins from accidentally not sending this information back to the WebUI and causing bugs with loading settings.
There is one bug with loading WebUI settings which has been resolved with this pull request. The wrong WebUI settings were being loaded because of a race condition with writing to
uisettings.json
on the web server. This problem is now fixed.There is a new
WebUISettings
class for reading and writing WebUI settings on the web server. The WebUI settings are now stored inWebUISettings.dat
instead ofuisettings.json
. They are loaded and saved by therCache
class instead.rCache
will safely usleep the thread until the file lock is removed. The previous behavior was not to update the WebUI settings, if the file was locked.Future Improvements:
If this pull request is merged, it will allow for future improvements to be implemented for the WebUI settings. I did not include them with this pull request. It's better to have a smaller pull request to make code review and testing easier for everyone.
setsettings.php
. It will be possible to send multiple async requests at once without having to worry about the overhead. Also, a larger JSON string will be possible. This will make future improvements practical.