MENLO PARK, Calif. — Back when Android’s Gingerbread version was still fresh, Facebook engineers started seeing a problem — a big one, one that stood to kill the app on Facebook users’ Android phones.

Facebook had too many method records, the technical bits that let a service communicate with the app on your phone — in excess of 3 million method records, in fact. And 3 million was, in that version of Android, the magic number, the limit at which each individual app was capped.

It was Facebook’s big, mobile, “Oh, shit” moment. Then, over the course of two days, said Facebook engineering lead Mike Shaver, “We went from DEFCON 1 — klaxons and sirens, people can no longer use Facebook on Android — to the ability to extend the platform.”

In a chat at Facebook’s headquarters today, Shaver (pictured above) told a small group of reporters about how Facebook mobile engineers were able to pop the hood on Android — and never has anyone been more grateful for the open-source nature of that operating system — and find out exactly what and where the issue was. They quickly created a patch, moved a pointer in Dalvik, the Android version of Java’s runtime, and created more space for an app to store method records.

“We were able to send the patch over to Google to get their opinion on it,” said Shaver. “The looked at it for a day or two, and they said it would work for now, if not for the future.”

The teams did a bit of testing and rolled the patch out, saving the day for Facebook on Android.

Android has come a long way from its scrappy, crashy, buggy, early-adopter roots. The platform’s design and experience are, from a user perspective, at least equal to (and by some subjective measurements, far superior to) the more established iOS experience.

But without the technical capability to support massive third-party applications with global audiences in the billions, Android will not stand. That’s why Google needs Facebook. The social company is a huge competitor to Google in many other ways, but when it comes to Android, Facebook is the only app that can put the proof in the pudding and stress-test a mobile operating system for a worldwide audience.

“We’re a very significant app to them, and they’re a very significant platform to us,” said Shaver.

When it comes to building Android out for larger apps with more market share, he said, “These tools don’t exist because no one else has hit these limits. … All the [other] tools were designed for smaller applications.”

But, he continued, “Someone else will hit this limit. … We have all the tools. We know how to be this company. Everybody about Facebook is thinking about mobile, and everybody at Facebook is thinking about Android.”

When it comes to optimizations like these — tiny tweaks to a mobile OS runtime — Shaver rightly pointed out that the end user will never be able to see or feel any of this stuff. All they will know is that download times, app responsiveness, and features all stay bloat-free and quick. “The key is with these workarounds and limitations, it has to be transparent to the user,” he said.

But don’t hold your breath for Facebook to become a major contributor to the operating system in the future.

“What we have right now is an Android operating system with hundreds of millions of users that can have a great social experience,” said Shaver. “That’s the part we’re focused on.” As far as future patches or contributions to the Android operating system, Shaver said, “We’ll get that stuff out as it’s appropriate. … If that’s the thing we want to do, we’ll do it.”

Since last year, Facebook has been training engineers across all the company to understand and work with mobile technologies, with the end goal of company-wide “mobile empathy.” Hundreds have been given mobile training since last year, Shaver said 2013 is about putting that empathy and understanding to work.

Currently, Facebook is on an accelerated release cycle for all its mobile applications. The company updates its Android app every month on the second or third Thursday of the month.