You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/02/03 19:57:27 UTC

[GitHub] [airflow] alexbegg opened a new issue #21302: Pause auto-refresh when page is not in focus

alexbegg opened a new issue #21302:
URL: https://github.com/apache/airflow/issues/21302


   ### Description
   
   When running Airflow it can be common to leave some tabs of Airflow open but not active. I believe (but not 100% sure, if I am wrong I can close this issue) Airflow's auto-refresh keeps refreshing when the page is not in focus (for example, you switched to another browser tab).
   
   This is not desirable in the cases when you are running the Airflow services on your same machine and you have a long-running DAG (taking hours to run). This could cause your CPU utilization to ramp up in this scenario (which can be quite common for users, myself included):
   
   1. You are running the Airflow services on your same machine
   2. Your machine is not that powerful
   3. You have a long-running DAG (taking hours to run)
   4. You leave a auto-refreshing page(s) of that DAG open for a long time (such as tree or graph) in hidden (or non-focused) tabs of your browser
       - What can make this even worse is if you have multiple tabs like this open, you are multiplying the extra processing power to refresh the page at a short interval
   5. You have not increased the default `auto_refresh_interval` of 3
   
   ### Use case/motivation
   
   I am proposing the following improvements to the auto-refresh method to improve this situation:
   
   1. When you change tabs in your browser, there is a feature of Javascript in modern browsers called "Page Visibility API". It allows for the use of listeners on a `visibilitychange` event to know when a document becomes visible or hidden. This can be used to pause auto-refresh when the document becomes hidden.
       - Discussion on Stack Overflow: https://stackoverflow.com/questions/1060008/is-there-a-way-to-detect-if-a-browser-window-is-not-currently-active
       - MDN: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
       - W3C: https://www.w3.org/TR/page-visibility/
   2. Additionally, the older `onblur` and `onfocus` listeners on the entire document can be used too. That way if a user switches to a different window while the page is still visible, the auto-refresh can pause. If Airflow is not active, that likely means the user's attention is not on Airflow anymore, and there is no need to keep refreshing and using extra processing power to refresh.
   3. For all of this, we should provide a message in the UI to alert the user that the auto-refreshing is paused until the page regains focus.
   4. Lastely, the option to only auto-refresh on page focus should be a configurable settings. Some people may not want this.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] bbovenzi commented on issue #21302: Pause auto-refresh when the document becomes hidden

Posted by GitBox <gi...@apache.org>.
bbovenzi commented on issue #21302:
URL: https://github.com/apache/airflow/issues/21302#issuecomment-1034220312


   Good call! Feel free to DM me on the Airflow Slack if you need help with any part of the UI.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] bbovenzi closed issue #21302: Pause auto-refresh when the document becomes hidden

Posted by GitBox <gi...@apache.org>.
bbovenzi closed issue #21302:
URL: https://github.com/apache/airflow/issues/21302


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] alexbegg commented on issue #21302: Pause auto-refresh when the document becomes hidden

Posted by GitBox <gi...@apache.org>.
alexbegg commented on issue #21302:
URL: https://github.com/apache/airflow/issues/21302#issuecomment-1054566047


   I have been too busy lately to work on a PR for this, I talked with @bbovenzi and he can work on it in place of me.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on issue #21302: Pause auto-refresh when the document becomes hidden

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #21302:
URL: https://github.com/apache/airflow/issues/21302#issuecomment-1030904784


   assigned you


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org