Facebook’s Library Fresco Merged My Code

๐ŸŽ‰ WOOHOO! My code just got merged into Facebook’s Fresco Library that is used to benefit millions of end users.

โ˜๏ธ What is Fresco?

Fresco is a powerful system for displaying images in Android applications. It takes care of image loading and display so you donโ€™t have to. Fresco supports Android 2.3 (Gingerbread) and later.

Image Pipeline

Frescoโ€™s image pipeline will load images from the network, local storage, or local resources. To save data and CPU, it has three levels of cache; two in memory and another in internal storage.

๐Ÿ‘‰ Visit Fresco’s official website to look at its complete features.

Drawees

Frescoโ€™s Drawee shows a placeholder for you until the image has loaded and then automatically shows the image when it arrives. When the image goes off-screen, it automatically releases its memory.

๐Ÿš€ How I contributed code to Fresco?

I’ve been very active in the open source software community for over an year now. I’m an active contributor to orgs like Mozilla, Kiwix, OpenDataKit just naming a few. There’s a lot you can see on my GitHub.

๐Ÿ‘‰ Check out my open source work if you haven’t checked it yet.

A few weeks back, I tried using Fresco for one of my personal projects that impressed me so much that I committed to make this library even better.

I immediately forked the Fresco’s GitHub repo and there was an issue ticket that caught my eye.

It was the issue#2222 that talked about byte array handling. Handling exceptions has always been my thing and it was just that.

The consequences this bug could’ve had

This code belongs to the jpeg_stream_wrappers.cpp that was written in the native C++ code that will be bridged by JNI.

We must throw an exception if the java byte buffer is NULL or it will further process within the system.

  // allocate java byte array
  dest->javaBuffer = env->NewByteArray(kStreamBufferSize);
  if (dest->javaBuffer == NULL) {
      jpegSafeThrow(
          (j_common_ptr) cinfo,
          "Failed to allocate memory for java byte buffer.");
  }

These 4 lines of code helped us get away with such a nasty NULL java byte buffer.

Code getting merged

After working on the solution, I made the pull request and soon got feedback from Oprisnik who is a Software Engineer at Facebook London and also the maintainer of Fresco.

We’re almost there! After getting the code reviews, I got the good news that my code has been merged.

My Facebook’s GitHub contribution chart

The diamond looks great, isn’t it?

Honestly, I feel super happy that I could play my part in making a difference in people’s lives by contributing to a library that powers software used by millions if not billions of users.

I plan to continue contributing to open source and making a difference! And so should you too ๐Ÿ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *

Up Next:

Mentored Students about Open Source at Google DevFest '19

Mentored Students about Open Source at Google DevFest '19