Thursday, July 21, 2016

AdBlock - The browser killer

TLDR; This is not an anti-adblock post. The AdBlock extension is a proved CPU eater and it is proved that the AdBlock extension slows down your browsing experiences. I and many other devs suggest you "Ublock Origin" extension. Ublock Origin is fast and it has less bugs.


We had a CPU usage issue for a while ago with AdBlock users on onedio.com reported by some of our users.

At first we thought that this CPU problem is about user's system resources and we didn't mind too much.
After a while we started to get too many complaints about same issue. We dig into this then we saw that this is a problem about AdBlock extension. Yes the most popular ad-blocker extension in Webstore.

Here is a profile result for onedio.com with a Chrome browser + Adblock extension



The CPU killer function named addElemHideSelectors is a core function of Adblock. We searched about this function and we saw that this issue has been already reported on AdblockPlus Trac (not Adblock, AdBlock Plus) [1] [2] has been already fixed this by a very few code changes. [3]

So I reported the same issue on https://help.getadblock.com/support/tickets (which is a closed ticket system, where no one sees your ticket or process of the fix.) [4]



Then for long time we got no response. Even an automated response. We dig again and reviewed the Adblock source code. We focused on the problematic function and it's calls. [5]


We saw that there is too many array operations while collecting "something" with string match "source" and "track", and we have too many "data-track" and data-tracksource" and "data-source" attributes on our website. So we replaced these attributes with abbreviations  like data-trck or data-trcksrc. After this change immediately AdBlock problematic function's CPU usage decreased from %60 to %30.  See it from my second CPU profiling result


But we still didn't solve the CPU issue. We just relaxed our users a little.
It is sad that we should be Adblock compatible.

We then applied the patch that AdblockPlus have made to Adblock. Ad here is the result. The only problem is that Adblock iterating 172K size array without grouping and immediately.

Iterating array with groups and using slice instead of splice solves this problem. 


"The problem seems to be caused by ​the while loop inside addElemHideSelectors somehow." noted on AdBlock Plus trac page 
As a result we are struggling with AdBlock issues because they have very slow development processes or they develop nothing. If you really want an adblocker extension try Ublock Origin. It is fast. If you want an adblock extension that has "adblock" in it's name try Adblock Plus. But don't use  "AdBlock".  Popular doesn't mean it's the best.


1. Adblock and AdblockPlus is different projects but they share common libraries. 
2. The issue reported on AdblockPlus https://issues.adblockplus.org/ticket/4036#no1
3. Fix for the issue on AdblockPlus repo https://hg.adblockplus.org/adblockpluschrome/rev/9f451f809d40
4. AdBlock ticket system https://help.getadblock.com/support/tickets
5. The js file of AdbBlock that we analyzed https://gist.github.com/hasantayyar/6c5b6139316a9c5e24675bfa89980c4c


Update from my mentions to @getadblocker





Update #2
After Adblock released it's 3.1 version our pains are gone.



Sunday, July 3, 2016

How we make decisions at Onedio?

At Onedio.com while we are making decisions we are using natural and primitive methods like our communication that I've mentioned here.

Short answer: We talk, like all we are team leaders. We decide all together. There is no long answer for this. And this is not magic. Try it.  It is like deciding what to eat all together. Just make a free and natural office environment that everybody can talk.   

If you want some diagram for our decision steps here is an unnecessary diagram.





Other "How we do X at Onedio" posts 
- How we overcome monday morning syndrome at Onedio http://tayyar-code.blogspot.com/2016/06/overcome-monday-syndrome-onedio.html