search
HomeWeb Front-endCSS TutorialCSS will crash the app

CSS will crash the app

Jan 23, 2017 pm 03:11 PM

The CSS code I’m going to talk about today really crashes the app. As for whether you believe it or not, just look at the picture.

CSS will crash the app

I suddenly received an email. The content probably said that the app crashed due to CSS issues. At that time, I was thinking, what kind of CSS is so awesome that it actually makes the app hang? So I took out my mobile phone and opened it according to the URL prompted in the email. I just want to say, this code, uh, forget it, let’s not complain. In fact, if I wrote it, it would definitely be worse.

Although it is a page from another department, as a member of the company, how can you not consider the company's products. It sounds like flattery, but it really is, because what I am most curious about is the cause of bugs. Of course, I must also care about the product.

So I went to the company early the next morning and started demining...

I looked at the code carefully, and started investigating from the initial suspicion that the performance of animation affected the operation of low-end devices. It turned out that this so-called performance problem was actually not that serious. We couldn't find a clue for a while, and the source file was not on our side, so we had to open the vase and grab the CSS file, then replace it and check it bit by bit using the delete method.

Finally, judging from Master Chu’s suggestion and the URL provided, it turned out to be caused by rem.

Everyone should know that this website is specifically for checking bugs. Of course, you can also report bugs.

@-webkit-keyframes crashChrome { 
        0%{ -webkit-transform: translateX(0rem);} 
} 
.anim:before{ 
    content: ""; 
    width: 3rem; 
    height: 3rem;     
    border-radius: 3rem;     
    position: absolute;     
    left:5rem;     
    top: 5rem;         
    background-color: #06839f;         
    -webkit-animation: crashChrome; 
}
<div class="anim"></div>

When I first saw this CSS code, I felt that there was nothing wrong with it. Isn't it just using the :before pseudo-element to create an animation animation effect, and then using the rem unit.

It’s really puzzling.

Let’s find a test machine and continue to delete the problematic page code. First I used Samsung's and found that there was no problem. Then I used Xiaomi's and it crashed. After looking at the versions, Samsung’s is Android 4.4.2 and Xiaomi’s is Android 4.4.4. Is it related to the versions?

In short, I spent a long time troubleshooting the part with animation effects at the beginning but still couldn’t find the problem. Finally, go back to the page where the bug has been reported to read the detailed instructions.

It suddenly occurred to me that :before was used to create animations in this page. Could it be that it is also used in this page of ours? So after a search, the result was that it really does exist!

Hurry up and try this code on our own page, and finally find you. Quickly reply to the email and tell the other party...

Thank you again, Master Chu, for your tips. I have the opportunity to learn about a problem that I have never understood.

This bug has been solved in current desktop devices. According to the bug list page, the bug was found in

Chrome Version: 34.0.1847.116 (Official Build 260972 ) m

on this version and available in all systems. However, Chrome is now version 50 or above, so there is no need to worry about it on the desktop.

But since I met it on the mobile terminal this time, and it is Android 4.4.4 version, although it was found in Xiaomi 3, Android 4.4.4 version should be relatively common. Is it possible? That's really going to be the problem.

CSS will crash the app

Get the UA information of this webview and see that one of them is Chrome/33.0.0.0 Mobile Safari, so I thought, maybe it is related to this webview , after all, I checked it in every browser on the Xiaomi Mi 3 test machine and found no problem.

Now we know that this bug will occur when rem and animation are together, but there is no problem in other elements.

Then I started to do various experiments:

Changed animation into transition, and also changed the properties with rem. It turned out that the result of this idea was that there was no problem.

Thinking that :before is a pseudo element, there are several selectors for pseudo elements, try them all.

CSS will crash the app

It turns out that all four pseudo-element selectors will crash the page...

I don’t understand the underlying rendering mechanism of the browser (webview). But for now, it may be due to a problem with the version of Chrome/33.0.0.0 Mobile Safari. If animation is used in a pseudo element and the value of rem is changed, the page will crash.

So, maybe it should be like this:

Use one of the pseudo elements such as :before to do the animation;

The animation changes one of them The value of rem;

Under this premise, if you use a version of the browser with this bug, the page will crash.

If you want to avoid the occurrence of this bug, then it should be:

Change to a webview, a higher version should be better;

When using animation animation in pseudo elements , no need to use rem unit;

But it seems that now everyone will use rem units, and then also use animation to animate, so that’s good, instead of using two things on pseudo elements.


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Powering Search With Astro Actions and Fuse.jsPowering Search With Astro Actions and Fuse.jsApr 22, 2025 am 11:41 AM

With Astro, we can generate most of our site during our build, but have a small bit of server-side code that can handle search functionality using something like Fuse.js. In this demo, we’ll use Fuse to search through a set of personal “bookmarks” th

Undefined: The Third Boolean ValueUndefined: The Third Boolean ValueApr 22, 2025 am 11:38 AM

I wanted to implement a notification message in one of my projects, similar to what you’d see in Google Docs while a document is saving. In other words, a

In Defense of the Ternary StatementIn Defense of the Ternary StatementApr 22, 2025 am 11:25 AM

Some months ago I was on Hacker News (as one does) and I ran across a (now deleted) article about not using if statements. If you’re new to this idea (like I

Using the Web Speech API for Multilingual TranslationsUsing the Web Speech API for Multilingual TranslationsApr 22, 2025 am 11:23 AM

Since the early days of science fiction, we have fantasized about machines that talk to us. Today it is commonplace. Even so, the technology for making

Jetpack Gutenberg BlocksJetpack Gutenberg BlocksApr 22, 2025 am 11:20 AM

I remember when Gutenberg was released into core, because I was at WordCamp US that day. A number of months have gone by now, so I imagine more and more of us

Creating a Reusable Pagination Component in VueCreating a Reusable Pagination Component in VueApr 22, 2025 am 11:17 AM

The idea behind most of web applications is to fetch data from the database and present it to the user in the best possible way. When we deal with data there

Using 'box shadows' and clip-path togetherUsing 'box shadows' and clip-path togetherApr 22, 2025 am 11:13 AM

Let's do a little step-by-step of a situation where you can't quite do what seems to make sense, but you can still get it done with CSS trickery. In this

All About mailto: LinksAll About mailto: LinksApr 22, 2025 am 11:04 AM

You can make a garden variety anchor link () open up a new email. Let's take a little journey into this feature. It's pretty easy to use, but as with anything

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor