Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27650 closed defect (bug) (invalid)

Possible interference between media upload progress bar and window.requestAnimFrame calls

Reported by: zipzit Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Media Keywords:
Focuses: Cc:


I wrote a simple little plugin to help troubleshoot CSS @media calls. The plugin added a small box to the corner of the screen, and updated 4 / second via window.requestAnimFrame calls. When that plugin is activated, the media upload stalls out or comes back with "An error occurred in the upload. Please try again later” error message. When the system stalls, the screen is locked, my plugin no longer functions. It doesn't happen until the upload media progress bar is nearly 100% complete. The images have uploaded fine (I can check the uploads directory via FTP) The whole thing is odd. The critical parts of my plugin code:

function dev_tool_window_size(){
    <div id="dev_tool_window_size" style="position: fixed; top:33; right:0; min-width:50px; background-color: blue; color: white; z-index: 100000;">
    window size

    <script type="text/javascript">

    function checkScreenSize(){     
        document.getElementById('dev_tool_window_size').innerHTML= 'window size:  (code removed for WP error test) ';

        // shim layer with setTimeout fallback
        window.requestAnimFrame = (function(){
          return  window.requestAnimationFrame       || 
                  window.webkitRequestAnimationFrame || 
                  window.mozRequestAnimationFrame    || 
                  window.oRequestAnimationFrame      || 
                  window.msRequestAnimationFrame     || 
                  function( callback ){
                    window.setTimeout(callback, 1000 / 4);  /* update 60 per second?  4 times per second is just fine.  */

        (function loop(){
add_action('wp_loaded', 'dev_tool_window_size' );

I think this means that anybody running html5 animations using window.requestAnimFrame will receive error messages when they attempt to upload media. Is this intended behavior?

Complete plugin will be attached to the ticket.
Feel free to call or text or email anytime..

Attachments (1)

dev_tool_window_size.php (3.3 KB) - added by zipzit 8 years ago.
Plugin I wrote that help exhibits the error.

Download all attachments as: .zip

Change History (3)

8 years ago

Plugin I wrote that help exhibits the error.

#1 @ericlewis
8 years ago

  • Resolution set to invalid
  • Status changed from new to closed

wp_loaded is triggered too early to drop in scripts and HTML bits - before the <html> tag is even opened. That's why you're getting the errors.

I would suggest checking out wp_enqueue_script() for script enqueueing and the admin_footer for adding in random HTML to the admin interface.

#2 @DrewAPicture
8 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.