DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Circle Text With CSS and JavaScript
  • How it Feels to Switch from Eclipse to Android Studio
  • How To Develop a Modern Image Gallery With HTML, CSS, and JavaScript
  • Reasons to Use Tailwind CSS in React Native Development Projects

Trending

  • How To Deploy Helidon Application to Kubernetes With Kubernetes Maven Plugin
  • An Introduction to Build Servers and Continuous Integration
  • Build a Digital Collectibles Portal Using Flow and Cadence (Part 1)
  • No Spark Streaming, No Problem
  1. DZone
  2. Coding
  3. Languages
  4. Safari's Lazy Repaint Bug on iOS 7

Safari's Lazy Repaint Bug on iOS 7

Niels Matthijs user avatar by
Niels Matthijs
·
Sep. 27, 13 · Interview
Like (0)
Save
Tweet
Share
19.03K Views

Join the DZone community and get the full member experience.

Join For Free

Last week, iOS 7 finally saw the light of day. For Apple, it was an important step away from their original mobile design paradigms. I, on the other hand, was looking forward to the new Safari (which always comes bundled with major iOS updates), at least until I actually took it for a spin. Apart from some dreadful UI problems that are sure to haunt us in the coming months, I saw some rendering bugs I really wish I hadn't.

It's not entirely unnatural for stuff to break with a new browser update, yet one problem in particular stood out as quite perplexing. For some reason, the main navigation flyout on my smallest responsive view had stopped working. Rather than fail completely, the entire flyout just wouldn't appear unless you started to scroll a little, after which it reappeared where it was supposed to be. The thing that got me worried is that the code I used to make this flyout work is incredibly basic.

body #site {right:-17em; width:17em; position:fixed;} 
body.showSite #site {right:0;} 

Of course I have some extra CSS on there to make everything transition more smoothly between states, but even with that bit of code gone, it just wouldn't work. It didn't take me very long to remember a similar bug I once encountered, though. A nifty little bug on the Android Stock Browser I often use as an anecdote to illustrate what a crap browser that really is.

What happens is that browsers are getting a little too lazy for their own good. When a class is set (or removed) using javascript (and especially when it is set as high up the DOM tree as the body element), they pretty much have to run through the entire page to check whether one or more elements are impacted on CSS level (the extra class might trigger some extra selectors). In order to save time, some browsers are attempting an educated guess. Some attempts fail, painfully, which happens to be the case on Safari for iOS 7.

There are basically two ways to fix this. The first is to make sure the class is set on the element that is affected (you might even gain a minor performance boost), as the browser knows it should at least re-evaluate the element that received the extra class. Not too difficult, but not always possible when multiple elements on a page are affected by a single state change.

 body #site.showSite {...} 

The other fix is to force a repaint on the element with JavaScript. On Android Stock Browser, you could fix things by applying zoom:1; (which felt rather appropriate), and on the latest Safari for iOS z-index seems to do the trick.

 $("#site").css("z-index", "5"); 

It's a bit worrisome to see such bugs introduced in the latest update of what is one of the oldest browsers on mobile. I understand the pressure they face to improve performance with each new iteration of their browser, but this clearly shouldn't go at the expense of faulty rendering/lazy repaints. This really is basic CSS that shouldn't be allowed to break, but sadly, I don't expect to see a fix for it any time soon.


IOS 7 SAFARI Element CSS Android (robot) mobile IT JavaScript

Published at DZone with permission of Niels Matthijs, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Circle Text With CSS and JavaScript
  • How it Feels to Switch from Eclipse to Android Studio
  • How To Develop a Modern Image Gallery With HTML, CSS, and JavaScript
  • Reasons to Use Tailwind CSS in React Native Development Projects

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: