UKC

ARTICLE: Rockfax Digital Deep Dives, Part 0 - Topos

New Topic
This topic has been archived, and won't accept reply postings.
Cloggy on the Rockfax App (you can also use it in landscape, although it's rare anyone does)

Our developers go into some of the technical aspects of how the Rockfax app works under the hood.



Read more
 Garethza 28 Apr 2020
In reply to UKC/UKH Articles:

Great insight, thanks for that and one can see how it must have been an absolute PITA to rewrite the app for android when it was all based around iOS in the beginning, but hey it had to start somewhere! 

 lithos 28 Apr 2020
In reply to UKC/UKH Articles:

that was cool.

do you need an alpha channel for displaying topos ? could save some space !

In reply to Garethza:

Martin (our Android developer) loves a multi-year challenge luckily =]

In reply to lithos:

It's a good point. No, we don't, and it's possible (in iOS terms) that the os doesn't need this information if you set `layer.isOpaque = true` on the backing layer of the tiling view, but I'm not sure. I guess that would make sense, but I've only ever thought of doing that to prevent the layer having to go through a compositing phase for the layers beneath if there's not needed.

In reply to lithos:

I've just spoken to Martin about this. In the Android version he passes in a flag to the image decoder to specify no alpha, which was apparently a necessary optimisation to get things performant. JPEGs inherently have no alpha channel, so that seems a bit weird to me. Things are a bit different in iOSLand, where it's the backing layer of the view that's dealing with the alpha. 

I load the image from disk, then draw it into a drawing context for one of the layers, which does have an alpha channel. I've just set this layer to opaque to see if I can see a corresponding reduction in the memory footprint, but the profiler has stopped working for the moment = If I can get it working I'll report back.

 remus Global Crag Moderator 29 Apr 2020
In reply to UKC/UKH Articles:

Really cool article! Great to see the evolution of the design and how you solved the different problems that came up.

How much did you end up writing in Ruby before you (presumably) ported it over to a new language? Was it hard work making the transition?

With the chopping for the tiles I was surprised to hear you did that by hand. Is this something you've automated now? Or is there some hidden complexity that makes it tricky?

In reply to remus:

Hey Remus!

> How much did you end up writing in Ruby before you (presumably) ported it over to a new language? Was it hard work making the transition?

It was, give or take, the topo view without any paging mechanism, and a partial crag list from what I remember. I'd worked on it for about three or four months by that point, and I was running into issues with RubyMotion that I was struggling to diagnose. The extra layer of technology was just adding to the complexity, and I'd come to the realisation that I needed to know the frameworks and Objective C just as well as if I was using them directly, as all the docs were in Objective C, so I may as well use the system Apple wanted me to.

Luckily, the ruby version acted like a prototype, and it's pretty quick to port something to another language once you've figured out all the mechanics.

> With the chopping for the tiles I was surprised to hear you did that by hand. Is this something you've automated now? Or is there some hidden complexity that makes it tricky?

I should probably revisit that part of the article to make it clearer. Initially, I used a tiling application I downloaded from somewhere. I just did a single topo - Stoney Electric Quarry - by hand, and I used that for all my prototyping. Now all this is automated with a custom mac app.

The problem at the start was bootstrapping the system. I didn't know for sure that I was going down the right path with any of the architecture, but I needed eg these tiled images to make the topo view, and data to feed in to draw the overlay, so I bodged it together a bit by hand and a bit by making throwaway scripts. 

 Toerag 29 Apr 2020
In reply to UKC/UKH Articles:

Interesting tip about the decoded image size, I didn't know that

 remus Global Crag Moderator 29 Apr 2020
In reply to Stephen Horne - Rockfax:

It sounds like the ruby version acted as a pretty good prototype for the objective c version! In some ways I guess it was a bit of a double win because  you'd have a decent idea of what you wanted to do so you could focus on learning obj c.

> I should probably revisit that part of the article to make it clearer. Initially, I used a tiling application I downloaded from somewhere. I just did a single topo - Stoney Electric Quarry - by hand, and I used that for all my prototyping. Now all this is automated with a custom mac app.

Phew! I had nightmarish visions of somer poor intern locked in the basement doing all the pics by hand

 Mark Lloyd 29 Apr 2020
In reply to Stephen Horne - Rockfax:

The RubyMotion website suggests you can target iOS as well as Android this obviously wasn't always the case so if you had stayed with it could have had one code base. Is swift the prefered choice now on apple devices ?

In reply to Mark Lloyd:

I followed the rubymotion project for a few years even after I stopped using it, but I'd forgotten about the Android support. You're right, this wasn't available at the time. But I wouldn't choose it for a project like our app if we were starting it today for a couple of reasons:

- I would only pick a staticly-typed language for anything of this complexity.

- The cross-platform bit of rubymotion doesn't actually mean you have one codebase; you still have to write platform-specific elements. 

I'm a big fan of ruby, but I only use it these days for very small projects. I find I can quickly write neat code that's very expressive with it, especially for things like text parsers, but when I come back to the codebase a few months later and don't remember how it works, the lack of explicit type-declarations makes it harder to understand what's going on. 

People do write massive systems in ruby, but I prefer to lean on the compiler more. 

The only cross-platform framework I'd consider for our app would be Google Flutter, where you can truly have a single codebase because it provides a totally separate graphics rendering system. But again, it wasn't available when we started, which was 2014 or so.

Post edited at 01:38
In reply to Mark Lloyd:

I forgot about your other question: Swift is very much the language of choice for Apple platforms. It's changed a lot since it was released and it's a great language now. 

 Mark Lloyd 30 Apr 2020
In reply to Stephen Horne - Rockfax:

I assume by that you are using Swift now, Object C memory management by reference counting was always a ball ache

 Mark Lloyd 30 Apr 2020
In reply to Stephen Horne - Rockfax:

Interesting that you think dynamic typing reduces readability, maybe that's why python has type annotations now, also to help third parties using your code.

It's good to have another language in your back pocket that you can knock up some quick code with, I find python ideal for that, ruby is not maybe everyone's choice unless you came to it from Rails.

In reply to Mark Lloyd:

> Interesting that you think dynamic typing reduces readability, maybe that's why python has type annotations now, also to help third parties using your code.

More like it reduces my ability to understand it quickly. If the types aren't written there for me to see I have to figure out what they are by reading around the codebase. If you're passing an object called `routes` into a method, is that an array, a set, a dictionary/hashmap? You can do that with documentation, but without the compiler forcing me to do it I never keep it up to date.

> It's good to have another language in your back pocket that you can knock up some quick code with, I find python ideal for that, ruby is not maybe everyone's choice unless you came to it from Rails.

I'm one of the few ruby developers who's never used rails. I can't remember how I got into it, although I remember I used python first.


New Topic
This topic has been archived, and won't accept reply postings.
Loading Notifications...