Realm Blog

Tim of iComics

iComics Screenshots

When we discovered that Tim Oliver, the creator and developer of the comic book app iComics, chose to migrate to Realm, we were thrilled. Not only is his application impeccably executed, but since he made the switch, he’s been very supportive of our product. We jumped at the opportunity to speak with him one-on-one to learn more about his story.

Tim Anglade, VP of Product at Realm: I know you’re based in Perth, Australia. Is that where you grew up?

Tim Oliver: Yeah, I was born in Perth, and I’m 28 years old now. I’ve been in Perth all my life. Although I did move to Japan for eight months last year to work for a company in Tokyo doing iOS development there.

Tim A.: Nice, were you doing regular iOS development for a public-facing application? Or internal development?

Tim O.: It was for a company called Pixiv. They’re probably the leading service in Japan for illustrators and artists. It’s a website where people can upload their artwork, their drawings, and their paintings for critique and that sort of thing. So I was working on the iOS team for that company.

TA: Nice. We’re actually getting really popular in Japan for reasons that have escaped me, because we haven’t done very much to advertise or get the word out there. But we have some pretty heavy users. Our activity and visits are off the charts, so I’m really excited about doing more stuff there.

So, can you tell us a little about how you got into iOS app development?

TO: Boy, that’s a long time ago. Basically when the iPhone 3G first hit Australia, I was really amazed at it, because it was the first time I’d actually seen things like websites running on a phone that didn’t look really nerfed. And I became really interested in learning how to program for it. I got a bunch of books and took a bunch of classes. The amount of power it gives you in a mobile device… I was hooked on it. And ever since then, I’ve just been writing iOS apps.

Tim Oliver

TA: And you started building iComics fairly early, right? You’ve been building that for a long time.

TO: Yeah, I started that one at the end of 2011, and I shipped the first version the third quarter of 2012. Since then I’ve been working on this current version. iOS 7 was a bit of a curve, so I had to redesign quite a bit of the app to get it to look nice.

TA: Let’s talk about the app. Where did the idea come from?

TO: I had the idea for a comic book reader ever since I got my very first iPad. I figured that an iPad would be the perfect device for reading comics. The landscape of computer screens means you kind of have to shrink the screen down, and the iPhone was way too small back then. I thought, “There’s probably a good market for this.” There were a few other readers out there doing what I was intending to do, but I felt like I could do a better job than those people, just in terms of performance and speed and things like that.

TA: Yeah, you have to be honest — the experience is pretty amazing. You have this blog post on your website that’s very insightful about comiXology versus iComics, and the different goals for the applications. Maybe you could talk a little more about that.

TO: That was hilarious. When comiXology got acquired by Amazon, a lot of my friends were like, “Ooh, what do you think about that, Tim?” I was like, “What do you mean, ‘What do I think about that?’ I’m not really competing with those people.” [Laughing]

Basically, comiXology was kind of a different model. They were like an app store with a reader duct-taped to the side kind of deal, where you buy comics off them and read them in their own proprietary reader. There was a bit of a kerfuffle this year when they got acquired by Amazon, and then in a move that seemed to be purely to make more money, they removed the store component from the app and made it like a really nerfed reader. And you had to go buy the comics from the website, which really ruined the experience for a lot of users.

So anyway, I thought I’d write a quick blog post about that just to highlight that that’s not really my model. I’m trying to make a reader that’s open to any type of comic that anyone wants to put into the app. I just wanted to let people know that I think that comiXology’s model is definitely a lot more profitable than mine, but at the same time, it’s very different.

TA: Yeah, and you really focus on the reading experience and do a beautiful job at that. I’m a heavy user of all these apps and it’s funny how broken it still is, and how hard it is to actually read comics and have a good experience reading comics, given those apps are probably generating millions and millions of dollars. So I definitely appreciate your focus and your approach on, “Hey, let’s nail the reading experience,” and the contrast is just amazing as opposed to all these apps.

TO: That’s exactly what I want to hear. Thank you so much for that. I should also mention that since then comiXology has also now made it so you can actually download comics you bought in DRM-free formats. So if you want, you can buy comiXology comics now and then load them into iComics.

TA: Yeah, they better do that because as you mentioned, it’s like an app store with a reader duct-taped to it, but then they removed the app store [laughs], so there wasn’t much to be using it for. But I know that’s the basis of pretty much all the DC Comics apps, the Marvel apps, and all the other ones, and yeah, it kind of shows. They did a good job early on, I think, of cornering that market, but I wish the app was a bit more polished. I wish I could read all those big catalogs and give publishers my hard-earned money and get a good reading experience out of it, but maybe at some point they’ll fix it.

TO: I’m hoping so too.

TA: So as you kind of alluded to, just so people really understand, this is a comics reader where you can load your comics in Zip, CBR, or those usual formats, and just be able to have a great experience using it. I don’t get to do this often, but I really recommend people go to the iComics website and to the iTunes listing because you have a very professional presence for this application. The website is beautiful and does a really good job of explaining it. You have a press kit that’s really interesting too, in terms of understanding high-level what you’re trying to do with the application.

TO: Thank you. I put that up, like, 10 minutes ago.

TA: [Laughs] I was just doing rounds through your website to make sure I wasn’t missing anything, so that worked out.

So what are you most proud about in the application? Obviously there’s a lot of polish, a lot of different things going on. But if you had to pick one or two features that were really exciting, what are you the most proud about in terms of the details that you achieved with the application?

TO: The thing I like the most is the speed. One thing I noticed back when I was thinking about writing a comic book reader app was that with all the other comic book reader apps, you can feel that there’s a bit of choppiness, like when you turn a page there’s a bit of a delay or slow FPS. And as I was developing iComics I found out why. It’s because actually decoding that much JPEG data on the fly can cause a really bad performance hit if you do anything on the main thread. I spent a lot of time — a couple months — just researching the Apple forums and Stack Overflow to figure out how to actually offload to a set of background threads. So as you’re reading the comic, iComics is preparing pages in advance, but it’s never touching the main thread. What you get is a very, very smooth reading experience, where you can swipe between pages with absolutely no juddering or any delay at all. I’m proud of that effect, and I don’t think anyone else has actually replicated it yet.

TA: Its smoothness is very impressive, and I was going through your reviews in the App Store, and so many people comment on that and are able to notice that experience. So I think that’s probably the reason why you get such a high rating. 4.5 stars is pretty unheard of for an app like this, so that’s really impressive.

What technology do you use internally? Obviously you use a little bit of Realm. Do you use any other libraries or anything else interesting?

TO: The library I’m using for decompressing all the comic archives is something called XADMaster, and it’s pairing an app from the Mac called the Unarchiver, which is really, really good. It can handle a huge amount, any kind of compression format.

Most of the stuff in the code I’ve written on my own, like the pullout tray, and even the grid view is all custom, just so I could get proper control of it. There’s not much else. I think Realm is probably the biggest third-party library in there at the moment.

TA: Interesting. It’s not uncommon, actually. I was surprised — I was expecting people who use us in the early months to be people who use a lot of libraries and kind of do LEGO-style applications, you know, building blocks put together. But instead, it seems like we’re fairly popular with people who don’t use a lot of libraries in their applications. That was kind of unexpected for me.

So, speaking of Realm, what do you use it for specifically?

TO: Basically, there’s a bit of a really big persistence back into the app. There’s probably two main components. The first one is there’s a lot of metadata attached to each comic, so when you actually import a comic into the app, it stores things like the size, the format, when it was imported, what page — it saves states, things like what page you were on when you last hit close, and additional things like the reading settings — is it a left-reading comic or a right-reading comic? And then there’s additional things like metadata for the collections, and coming soon I want to add bookmark support as well, so you can bookmark pages. So there’s also a stop in there for bookmarks.

The second component is basically the way the pages are cached, because you can have comics out there with incredibly large pages that can’t just be loaded straight into video memory. What actually happens is when you are reading a comic, it’s analyzing all the pages in advance and seeing which pages might need to be resized before they can be displayed on the screen. So there’s actually a separate Realm for each comic — a Realm file that tracks the properties of each page just to make sure that it’s been analyzed and it’s OK to display on screen and won’t overflow the video memory or anything.

TA: Nice, that’s interesting. I haven’t seen a lot of people do that yet. Obviously SQLite is used as a file format for different applications fairly commonly. But I haven’t seen people do that with Realm yet. You’re probably the first person I’ve talked to that’s using it in that way. So you store that representation basically alongside all the JPEGs, the images, and you’re using one Realm file per comic with different records for each page?

TO: Yeah, one Realm file per comic stored in the cache’s directory.

TA: Cool, that makes a lot of sense. As you probably noticed, it’s very fast to serialize and get that information.

TO: Oh yeah, it’s really fast. I love it.

TA: That’s perfect. So obviously you were using Core Data before, right? Was it hard to switch, and what were some of the reasons you decided to switch?

TO: Well, the original reason why I used Core Data, I was going to use just raw SQLite at the start, but a couple of my friends here said, “No, you should use Core Data. It’s the best. It has all these cool new features that SQLite wouldn’t offer on its own.” So I gave it a try, and I stuck with it for two years, and it’s not bad, but oh boy can it be a pain to work with threads. Anything thread-related, Core Data can do all sorts of really weird things, like corrupt databases and corrupt rows. But it was fine for two years. I managed to sort it all out through a lot of forum searching, a lot of Stack Overflow posts.

But the kicker recently was when I went to update the app with the new version on top of an old App Store version. However the order migration process works, it was just sort of silently failing, and I was getting a lot of corrupted databases, which is terrible for users. Because all that meant that the app started crashing really consistently. And after looking at how much effort it would have taken to try and work out how to mitigate this order migration error, I figured maybe it’s time to bid farewell to Core Data and try something else.

One of my coworkers at the development firm I work for had discovered Realm early this year, and he was definitely recommending it. And when this happened I thought, “This is probably the best chance I’ll get. I’d better migrate to Realm now and see if it’s going to fix my problem or make it worse.” And I was really impressed. I basically managed to tear out Core Data and replace it entirely with Realm in the space of about five hours.

“I basically managed to tear out Core Data and replace it entirely with Realm in the space of about five hours.”

TA: Wow.

TO: So that was ludicrously quick. I was amazed at how quick it was. I installed it into the code base really, really quickly and easily. It follows the same general pattern of Core Data, so I didn’t have to modify the model objects too heavily or anything. And yeah, straight off the bat it worked fine, and it was a lot more stable than Core Data.

TA: That’s interesting. I’m assuming the code base isn’t small, right? This is a fairly complex application. What are we talking about in terms of number of lines of codes, roughly?

TO: About 150,000 lines of code.

TA: Yeah. [Laughter]

TO: Most of that’s, like, XAD library and things like that. But yeah, it’s not a small code base at the moment.

TA: Five hours is pretty good. We try to optimize for that, obviously — how easy it is to get started. But I’m always amazed how straightforward it is for people to switch. I think people expect it to be somewhere near the amount of time it took them to write the Core Data parts in the first place. But it tends to be a lot shorter.

TO: Yeah, so quick.

TA: Is there anything else that you like about Realm? And, also, what things aren’t so good yet about Realm?

TO: The thing I liked the most about it was just how much code wasn’t necessary to get it up and running. I mean, accessing the default Realm is literally just a single static method, which is incredibly nice and simple. And the model objects, all you need is the properties and that’s it. So it’s incredibly easy to get up and running with very minimal amount of code, which I loved about it. And it runs really fast.

I guess the thing I didn’t really like — well, it’s not that I hated it, I understood it — was the problem that you couldn’t actually move objects between threads. A lot of the time in iComics, I’d be working on a comic object in a background thread, and then I’d save to the main thread. I’ve updated it with this EUID. And I just passed the object across the thread, and then pulled the EUID object out of it, which I’m guessing is a bit of a no-no to begin with in multi-thread programming. But Core Data lets you get away with it; Realm didn’t. So that inherit strictness meant that I had to refactor a bit of code there. But it wasn’t too much of a problem.

TA: Yeah, obviously there are reasons why that’s there. If we allowed it, it’s basically a huge performance hit because every time you try to access an object, we have to check if you’re accessing the right copy for the right spread. We’re actually coming up with something for that. By the time people read this, it might actually be out already, where you’re going to be able to do queries in the background thread, and maybe even do writes on the background thread, and handle results on the main thread. So that’s coming out pretty soon. We’re actually deep into the implementation of that. And we’re going to try to go even further down that road. But like everything with Realm, we try to be smart about giving you the features that you want in a way that’s not really going to shoot you in the foot. [Laughs]

TO: Yeah, once I got the hang of it, it was very easy to get around. Just thinking about two other things. The ability to notify the main thread when a specific object gets updated would be nice.

TA: Yes, yes. That’s also coming.

TO: Yeah, I heard that one’s coming. And being able to specify a default path for where the default Realm file is generated would be nice as well.

TA: Yes, and I think we are… You know, it’s funny. I think we had that and we removed it, and now people are complaining about it. We didn’t think that people felt either way about some of that stuff, but now we’re getting feedback on that more quickly.

TO: My app actually exposes the documents directory by iTunes, and I had a few of my testers saying to me, “What is this weird .Realm file in here? Should I delete it?” I was like, “No, no, don’t touch that!” [Laughter]

TA: Yeah, I know we need to do that. But we thought that people would just use, like, a name to Realm, like one of the other Realms. But people really wanted the convenience of it, and I know that you wrote your own wraparound to avoid that, so I get it.

TO: What I actually did was a method swizzle, which is kind of a crazy hack, but it worked and it seems to be stable. But it’s not the best solution.

TA: Fair enough. The swizzle. You’re not the only person who has had some issues with default Realm versus other Realms and being able to cull named Realms more easily. We spend so much time optimizing the low-level stuff that sometimes we forget some fairly obvious stuff on the API. But that’s good feedback.

So overall, are you pretty happy with Realm? Would you recommend that other people use it in their apps?

TO: Absolutely. Yeah, I love it. I’ve been very, very adamant about promoting it. I think anyone who’s struggling with Core Data right now needs to switch to it. And after having a chat with a few of the other programmers, they said their main concern was the cross-process issue. But since you’ve already said that’s going to be cleared up soon—

TA: That should be merged in, actually. I think right now, if you use the latest version of the core, that should work. And we have a couple of fixes to do at the Cocoa level, just to make sure, but that should be soon. Definitely by the time people read this, unless we hit some major problem in the merging of the code.

We try to move as quickly as possible. Our focus is stuff you can’t work around yourself, and processes were definitely one of those.

TO: I’ve been very impressed with the speed the patches have been coming.

TA: Yeah, we’re a small team, but we try our best. You know, 17 people and almost all developers, but as you can imagine, we get quite a few requests and there are quite a few things that we find. But we try to get rid of the bugs first and add the features that you can’t implement yourself, and last we’ll do stuff that is cumbersome.

So, any other cool apps or updates to iComics, or any interesting projects you’re working on that you can talk about?

TO: Oh jeez. Well this update took, like, over a year to do, so I was thinking of going on a little vacation. [Laughter] But I’m already compiling a list of new features to add. One feature that’s been really, really requested is the ability to lock collections. Apparently there are lots of families out there who have got, for example, dads who like to read rather violent comics that might not be suitable for kids. So they want to be able to lock certain folders, maybe with a touch ID or something, so others can’t get into those collections.

Apart from that, the other major feature people have been asking for is Dropbox integration so they could just download comics through the cloud instead of through iTunes. I’m still researching how to do that one, but hopefully it’ll be really straightforward.

TA: Cool, sounds really exciting. Well good luck with everything, and thanks again for chatting about the application.

Realm Team

At Realm, our mission is to help developers build better apps faster. We provide a unique set of tools and platform technologies designed to make it easy for developers to build apps with sophisticated, powerful features — things like realtime collaboration, augmented reality, live data synchronization, offline experiences, messaging, and more.

Everything we build is developed with an eye toward enabling developers for what we believe the mobile internet evolves into — an open network of billions of users and trillions of devices, and realtime interactivity across them all.

Get more development news like this