My favorite file in the Chromium codebase

    The Chromium code is very extensive, there everyone will find something to taste. But I decided to tell about my favorite file in it (do you have one?). This file reflects everything: pain, disappointment, hope, perseverance, willpower, responsibility for other people's failures and self-sacrifice. I sometimes read it and cry and i understand how much of the iceberg is hidden under water. This is, in general, not even a code file. This is a file with a config describing the video card bugs that Chromium has to bypass in order to properly display its pages on different platforms. Here it is:

    What is it all about? Let's remember how the browser works: you type some address in the address bar, the browser loads the content and displays it. A little more detailed about this is the good article “What happens when you type into your browser and press enter?” (And several of its Habré translations at once ). In it one of the last points is mentioned, they say, "and now that everything is ready, we draw a picture on the screen." Yeah, that's what we take and draw, of course.

    To begin with, in programming languages, for some reason, there is no “take and draw this on screen” function out of the box. Languages ​​and their standard libraries such trifles are not interesting. Accordingly, the universal cross-platform code for drawing is not so easy to write. Any kind of cool AAA games bypass this restriction quite straightforwardly: “You should have such a prefix, or this OS with a video card for 800 bucks, then it will work somehow. Probably". Thanks for the advice! But the browser is not a game. The browser should work always and everywhere. The user of even the most killed PC, purchased 10 years ago (and even then - on sale) does not expect to play the last Witcher, but will be genuinely outraged if he cannot open his mail in the browser or google something. On the other hand, and the gamer, who gave a kidney for the video card,8k-video, twist the 3D model, well, maybe even smoothly scroll the facebook tape.

    All this makes Chromium developers literally explode: on the one hand, they still support drawing with ancient technologies like GDI and DirectX9 to work on outdated equipment, but on the other hand they saw support for the latest versions of OpenGL, DirectX11 (or already 12?) And Vulkan - which makes it possible to expand on a full modern devices (including mobile).

    But all this would have been half the trouble if all this zoo worked as it should work according to the specification. What absolutely does not happen. Real hardware and its drivers break everything: marketing promises to customers, technical specifications, generally accepted standards, certification tests, OS compatibility, plans to release updates, etc. But besides the real hardware and its drivers, we have nothing else. Therefore, we have to work on what is. This is what the gpu_driver_bug_list.json file tells about .

    By the way, how much the browser tries to "survive at any cost" deserves respect. So, with non-critical problems, for example, with DirectX11, attempts will be made to disable certain parts of its functionality, sacrificing performance, but still maintaining performance. With more serious bugs - DirectX11 will be disabled and the browser will switch to DirectX9, where also (if necessary) problematic components will be “cut off and thrown out”. Well, with a complete failure of the DirectX system, switching to GDI will occur - which will hit the processor and the consumption of RAM, but still keep the performance for ordinary pages (without heavy video or 3D) at a level where the user most likely does not even understand that something is going wrong. Where other programs are already asked to update the driver or change the video card - Chromium will simply continue to work.

    Let's look at the contents of the file I mentioned. The number of individual entries in it: 215 pieces. 215 times when the developer of iron lied, was too lazy, was stupid or greedy. 215 times we had to look for the correct configuration of hardware and software to reproduce the problem and find its solution. It is difficult to say how many times it was decided not to fix the problem - but, since there are a lot of people around us with old iron and somehow very few people who do not open "Google Chrome", we can assume that there were very few such cases.

    The next interesting observation is OS distribution: 89 - android, 44 - macosx, 34 - linux, 26 - win, 8 - chromeos. Conclusions from here you can do different. On the one hand, it is obvious that the android is a key platform for Google and enormous funds were threatened to fix bugs. On the other hand, it is not clear why they were threatened with fixes in the Chromium code base, and not drivers or operating systems (after all, Google has a high level of control there at all stages). Corrections there would benefit all the software on the android, and here only Chromium. The most likely thing is the interaction of the departments, when it is easier for the Chromium programmer to correct the problem in his code here and now, than to escalate it 3-4 levels up, then to the side, and then 3-4 levels down. There are fewer people who are interested in this in any company than would be necessary.

    I was very surprised that the drawing bugs in Mac Os were found almost two times more than in Windows. It seemed to me that everything is very limited in hardware and licked in drivers. But it turned out that the Windows Zoo is twice as tenacious and stable. Straight "Cathedral and Bazaar" in the illustrations. Or just the Google developers themselves are testing the code on some Macs?

    The division by vendors is also interesting: Nvidia - 22, AMD / ATI - 17, Intel - 30. I don’t think that Intel’s software or Intel’s hardware is worse - rather, it’s the mass of the products. Anyone who does not specifically buy a “gaming PC” most likely buys something with an integrated Intel video card. The bug that happens in 0.001% of users will live for years in a video card from NVidia or ATI, but will lead a bunch of angry users in the case of Intel on the forums and on the social network. “Big power entails great responsibility.”

    It looks funny division on bugs OpenGL and DirectX: OpenGL - 16, DirectX - 0. But this is not because OpenGL is so bad, and DirectX is so good. The point here is that all the “win” category bugs (here’s those 26 pieces) are actually DirectX bugs (well, ok, not all, but almost all).

    But okay, enough is enough to accuse everyone in a row. Let's turn to the person , and there and to the massacre, you see, not far !

    Here, for example, record 211 , referring to bug 672380 . People have stopped working in the code unary minus and the arc tangent function on some hardware from Intel and NVidia. Unary minus , pancake, and basic trigonometry ! It would seem, in what further to believe? But no, corrected and works.

    Or here are the records about “incorrectly displayed colors” like # 185 , 219 , 220and some others. The programmer did everything right, all the functions worked and returned “success”, but as a result a pixel of the wrong color is displayed on the screen. Oh yeah - only here on these video cards and these driver versions. By the way, the question is to fans of the theory that everything can be covered with tests: how would you cover this with tests?

    Here's another cool thing, №224: "VPx decoding not supported Windows 10 creators update". Well, that is, the operating system came out, everyone trumpeted that it has acceleration of decoding such and such a video. But in practice it turned out that it is, but it is such that it would be better if it did not exist at all. And it's better to turn it off. As a result, the OS developer sells another billion of the paid OS, and the developer of a free browser collects complaints that the video does not play as smoothly as we would like, although it would seem that both hardware and OS should allow! “Where are my 60 fps and why did your browser eat 4 GB of RAM?” Is a familiar conversation, isn't it?

    And immediately catching her record number 225: "VPx decoding is too slow on Intel Broadwell, Skylake, and CherryView." We developed, so we developed new generations of processors one by one, advertised, sold. But the problems of the final user are the problems of the final user whom they care about. Let the appliedists somehow support there with a crutch, and then we'll fix it.

    A separate song - the so-called "Switchable graphics", which is very actively vtyuhivayut sellers in stores. Well, what a good laptop with two video cards - everything will be fast in games, and in office programs (like a browser) - it will be very energy efficient, Nn hours of battery life will work! And now we look at the bitter truth of life: on Windows, this will lead to a complete rejection of DirectX11 (entry # 100), and on poppies it will crash so often that we would better disable the non-discrete card altogether (record No. 228 ).

    Or here # 242 : "Triggers crashes in Marshmallow Adreno driver". The solution is also great: “dont_initialize_uninitialized_locals”. Well, what kind of normal people would agree to write something for the platform, where local variables can not be initialized when declaring, because from this the driver falls? But in the code of such a mass product as Chromium - you have to live with it.

    №26: "Disable use of Direct3D 11 on Windows Vista." DirectX10 was one of the main features of Vista with the release, and after some time DirectX11 came out of it, I still remember the boxes of video cards of those times with the proud words “DirectX11 compatible”. And for many, it was generally the only reason for the transition from the usual and stable XP. Years passed - and now support for DirectX11 (Microsoft product) in Windows Vista (Microsoft product) is rated at the level “not supported”. Direct recognition of merit!

    Okay, I'm sick of choosing particulars, read the rest for yourself - there are well described the causes of bugs, and the implemented crutches, plus links to the bugtracker (the “cr_bugs” field).


    First, everyone lies. Secondly, even under conditions when everyone lies, it is still possible to write high-quality software. And third, the next time someone will tell you how the modern web came to success thanks to “the power of HTML, CSS, and a beautiful Javascript language” — show him this article and ask how it all worked and who it was necessary without this heroic work of invisible people in an effort to "take off with all this garbage."

    Also popular now: