Addressing the delay of "Rasterize Paint" on mobile devices while implementing css3 opacity transitions

I'm currently working on a project that involves users navigating back and forth between modals. To achieve this, I decided to use CSS transitions to change the opacity from 0 to 1. However, I've encountered some issues with slow transitions.

Some of my transitions are experiencing lag delays ranging from 900ms to 2,000ms. In order to investigate the issue further, I connected my phone to my laptop using Chrome's remote dev tools https://developer.chrome.com/devtools/docs/remote-debugging and recorded performance events https://developer.chrome.com/devtools/docs/timeline

The screenshot shows the sequence of events captured on the phone. The yellow block represents the jQuery click event handler firing, while the vertical stripes indicate a jQuery.animate() function in progress. Interestingly, there is a lengthy green block at the bottom labeled "Rasterize Paint", lasting almost 2 seconds. The purple slivers on the right depict the actual animation taking place. (EDIT: The jquery.animate() function is distinct from the CSS animation occurring simultaneously. I am adding a class in the event handler to modify the opacity of an element with transition: opacity 300ms applied)

https://i.sstatic.net/RzJGe.png

What exactly does 'Rasterize Paint' signify? Why is it causing such a delay? How can I mitigate this issue?

EDIT: Below is a fiddle of the page where these slowdowns are happening. Due to the lack of a meta tag, there might be an additional 300ms delay on mobile devices. I recommend following these steps: "Got It! -> Fighter -> Accept -> Archery". The transition after selecting "Archery" seems to be the slowest. Any insights into why this specific transition is sluggish would be greatly appreciated. My suspicion is that overlapping opacities might be contributing to the delay, but I'm not entirely certain. https://jsfiddle.net/2fLb1fd2/4/

.step {
  position: absolute;
  width: 100%;
  max-width: 650px;
  background: rgba(16, 16, 16, 0.8);
  -webkit-transition: opacity 300ms linear, top 300ms linear;
     -moz-transition: opacity 300ms linear, top 300ms linear;
       -o-transition: opacity 300ms linear, top 300ms linear;
          transition: opacity 300ms linear, top 300ms linear;
  opacity: 0;
  top: -100px;
  left: 0;
  right: 0;
  margin: 30px auto 20px;
  padding: 20px 20px;
  color: white;
  pointer-events: none;
  text-align: center;
}
.step.showing {top:0;opacity:1;pointer-events:auto;}

Answer №1

The issue you're facing may not be related to opacity, as this property is typically light in terms of performance when it comes to CSS animations. It's likely that the problem lies with your use of animating the top property, which can cause reflow with each frame of the animation.

To enhance the smoothness of your animation, consider utilizing transform: translateY(x); instead of relying on the top property for your animations.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you provide instructions on how to replace the icon within the TablePagination element in MUI?

I'm currently working on a React project where I've implemented the MUI component known as TablePagination This TablePagination component is situated within the Table component, just like in the image provided below. https://i.stack.imgur.com/B ...

Is there a way to dynamically fetch and run JavaScript code from the server without resorting to the use of the

In my current project, I am developing a unique PHP framework that empowers PHP developers to effortlessly craft ExtJS interfaces containing forms, grids, tabpanels, and menus exclusively through PHP classes. To illustrate, creating a TabPanel in this fra ...

What is causing the unexpected behavior of deferred.resolve in the q manual?

I can't seem to grasp this concept and it might be a silly question. Let's analyze the code snippet below: function throwError() { throw Error("can't touch this."); } var def = q.defer(); def.promise.then( function() { co ...

What is the best way to display a webpage within an iOS app using PhoneGap?

In my iOS phonegap app, I am looking to have a single view that displays a web page. Can someone guide me on how to load this specific view with a particular URL using JavaScript? Although I primarily develop native iOS applications and do not have expert ...

Organize the array by property name and include a tally for each group

My current data structure looks like this: var data = [ { MainHeader: Header1, SubHeader: 'one'}, { MainHeader: Header1, SubHeader: 'two'}, { MainHeader: Header2, SubHeader: 'three'}, { MainHeader: Header2, SubHea ...

React Material-UI Table Cell departure event

I have a material UI table with editable fields within the rows. There are various events such as onInputCapture, onFocusCapture, and others. However, I am having trouble finding an event that should be triggered when I leave the cell or finish editing. ...

Tips for selecting a dropdown item that shares the same data-testid

I am attempting to use Selenium to click on an option in a dropdown menu. The options all have the same 'data-testid', and the only unique identifier appears to be the link text. Does anyone know of a way to select a specific choice within the dr ...

Transitioning my website to incorporate Angular JS

Recently, I have been exploring AngularJS and I am quite impressed with its features. I am currently developing a website using traditional methods (php, html, css, mysql, some jQuery) and I am considering transitioning to Angular. The reason for this chan ...

Using jQuery to detect changes in the value of form fields, excluding any changes related to display toggles

Currently, I am in the process of revamping a large form that includes various input fields and dropdown menus. The goal is to submit it via AJAX once a field loses focus but only if the value has been altered. To achieve this, I have set up a jQuery selec ...

Tips for relocating several buttons to the upper right corner

I have a dilemma with the positioning of 10 buttons on my webpage. Specifically, I would like to place them in the top right corner, but they are currently at the bottom. Can you assist me with moving the buttons? My desired outcome can be seen here. I s ...

Update the color scheme of text labels and the title on a 3D bar graph created with amcharts

After creating a 3D stacked bar chart, I have successfully generated the graph using the provided code. However, I am looking to customize the appearance by changing the font color of all labels and the title to a different color. While I was able to mod ...

Is there a way to define type information for a global variable when utilizing dynamic import within a function?

Here is a simplified version of my server code: server.ts import google from "googleapis"; const androidPublisher = google.androidpublisher("v3"); app.use('something', function(req, res, n){ ... }) ...(only one of the dozens of other meth ...

What could be causing my ul list to not be populated by ajax?

To populate the ul list with data from PHP code on page load, you can use the following ajax function. I appreciate any help in advance, and please forgive me if my explanation is not precise as I'm new here. This post contains mostly code snippets. ...

Tips on eliminating excess white space or margins beneath a flexible video player

My issue is with a video and some content underneath. When I reduce the height of the video on mobile, there is too much white space below it. @media only screen and (max-width: 600px) { video { height: 80%; } Instead of adding margin-bottom ...

The event SelectedIndexChanged is not triggering as expected on dropdown lists that are created dynamically

My Telerik RadComboBox triggers Javascript on change to fetch data from the database via AJAX and populate a second dropdown list. I need to fill text boxes based on the selection of the second dropdownlist. The code for the two dropdownlists is as follows ...

Can terminating a POST XHR request be trusted?

Running an apache server with PHP 5.4. I've set up a form that sends an asynchronous request to the server and stops any previous requests if the button is clicked again before the current request is completed. If I repeatedly click the button quick ...

Using Angularjs to bind an array element within an ng-repeat inside a directive

Having trouble displaying the elements of an array using ng-repeat with a directive. The binding is not working correctly and showing empty values. To view the code, visit http://jsfiddle.net/qrdk9sp5/ Here is the HTML: <div ng-app="app" ng-controlle ...

Why would someone opt to utilize process.env.PORT in their code?

Setting the environment variable PORT to a specific value, such as set PORT=5000, provides explicit instructions on which port the program should use. How does this method differ from simply instructing it to use port 3000? ...

Tips for querying Mongo using Node.js

Although this question may seem repetitive, please bear with me. My goal is to query MongoDB directly from the dom eventually, but for now, I'm working on querying from my routes module. Below is my query: var db = require('./config/db.js&apos ...

Store the current function in the cache, incorporate new features, and execute those additions upon calling another function

I have a pre-existing function that I am unable to directly access or modify. Due to this limitation, I have resorted to caching the function and incorporating additional functions alongside it. This function loads periodically, sometimes occurring on pag ...