Lag is the delay in the response of a computer's video output, which interrupts the standard latency. In more simple terms, it is often a slight or major freeze in the frame rate of the computer output. It occurs when information too large to be processed is handled by a computer processor unit (CPU) or graphics processing unit (GPU). Lag can also be affected by graphics settings in various computer applications, mainly games.
A computer's process can only take in and read so much data in a fixed amount of time. If too much data is pushed into the processor, it cannot read it in time and therefore cannot output the results. In terms of gaming, the output would be the video on the monitor or screen. If a computer's graphics processing unit is told to render extremely high graphics, it may not have the power and speed to do so in a timely fashion. Therefore, it takes longer for the video output to be displayed and delays or slightly freezes a game temporarily.
Another possible cause of lag is a computer's random access memory (RAM) being filled up. RAM is temporary data that can be quickly accessed to continue running programs. The more applications a computer is running simultaneously, the more RAM is filled up because the RAM itself is the data of the applications being used and accessed. Therefore, if the RAM usage is high, it can take longer to access binary code which could delay the time for the data to reach the processor and output. Mobile devices such as phones typically lack a large amount of RAM which makes them inefficient to run many apps at once.
Lag in gaming depends on the type of game being played, the graphics properties, and the computer's specifications. Games with large cities of high textures being rendered at high frame rates will generally lag more than a simple three-dimensional platformer. Lag has been an issue since the dawn of gaming and can either be solved by quality lowering or hardware upgrading.
- lower graphic options such as:
- shader effects
- shadow effects
- output resolution
- close other running programs
- play low-level programming language games
- download instead of stream games
Almost every game comes with graphics options which can be optimized for an end user's computer. In the image above, the computer rendered shadow, shader, brightness-enhancing, and anti-aliasing effects. If, for example, higher resolution textures were to be rendered, the game could lag and lower in frame-rate. Games come with options for lowering or raising graphics qualities, which can often be edited outside the game itself with settings files.
Games involving large worlds often have methods to prevent lag. In many open-world games, objects in the far distance will be rendered with low-quality graphics while nearer objects are rendered with high-quality graphics. Since distant objects appear smaller, lower quality graphics cannot easily be noticed in the objects. An example of this would be a very distant building in which the antennas are not rendered, but when the building comes closer to view, the antennas are shown. This keeps efficiency on the processor while having the capability to view large worlds of objects.
Lag in Scratch
The project editor can lag some when projects get very large. If a script consists of too many blocks, dragging the script can cause major lag due to too many block images being rendered. The Paint Editor can lag, too, if a vector object with an excessive amount of splines and control points is being manipulated. The more control points a vector image has, typically the more processing power it takes to render.
In the old Flash Player that used pixelbender, some graphic effects cause incredible amounts of lag due to Adobe's removal of pixelbender in Flash. Pixelbender was the code that accelerated graphic effects to make them render quickly and on very little processing power. With the removal, graphic effect rendering can cause CPU usage to reach over 90%, causing lag in projects and many Flash applications. A workaround can be opting-in to the Beta Scratch Player or by downgrading to version 11.7 of Adobe Flash.
Projects can lag also if too many clones are generated, especially on older computers. Also a huge amount of sprites and scripts can cause the project to lag.
Preventing lag in Scratch
There are a multitude of ways to lower the lag in the Scratch program, such as:
- using vector graphics
- avoiding the use of detailed vector graphics in motion
- avoiding the use of cloning
- using fewer sprites
- spreading out scripts across other sprites
- limiting the amount of objects visible at one time
- using custom blocks to fit long and similar scripts
Instead, a loading screen can be used to complete off-screen tasks.
The Scratch Website might lag if the visitor's Internet connection is poor, the server is overloading (when there are more requests to the Scratch Website simultaneously than it can handle), or there is a problem with Scratch's servers (which can result in HTTP 500 errors).
The rendering in a video game is meant to be so quick that the output occurs many times per second so the eye does not notice the latency delay. Movies, on the other hand, are different. An animated or CGI movie uses extremely higher-quality textures and models to render than a video game. This is commonly known as special effects. In the Lord of the Rings trilogy, which was developed from the late 1990s to the early 2000s, a creature called the Balrog had 10,000 textures all over its entire body that had to be rendered. For this time period especially, that was an immense amount of work for the computers of the era.
The rendering of such frames requires a lot of time and the top equipment available. Most importantly is a strong processor, graphics card, and RAM for studios such as Pixar to generate their motion-pictures. Companies often have large warehouses of computers dedicated to rendering graphics. Companies that design the movies will often pay these companies to use their hardware to render rather than their own. Movies can take days to fully render, though with more recent hardware, rendering has become less time-consuming.
Side-effects of lag
Lag can affect computers in many ways. Mostly, lag is mild and will only cause the software to run slowly. However, some lag can be major. Sometimes software will lag and freeze until it can run smoothly, and if it cannot run smoothly, it will simply hang, leading to frustration for the user. Lag can even "crash" and close the program suddenly. If a browser uses the Adobe Flash Player, the Flash Player will crash if too much memory is stored. Sometimes, lag can be very serious and can affect the whole computer such as freezing or hanging all of its controls or causing a fatal system error (usual signaled by showing the blue screen of death (on Windows) or any type of crash screen like kernel panic, if using Mac OS X or Linux). Lag usually does not damage computer hardware, though, and is solely related to software.