HTH Continuously Learning

Venice in spring

Link to album

This month I jumped on a plane to one of these places that I had expected not to see anytime soon, that always seems so exotic when you see and read about it in media. I was joining the 30th birthday party of my girlfriend’s friend in Venice, though I have also jokingly said I was there for the Biennale (Feneyjartvíeyringurinn in Icelandic) just to seem more refined than I actually am.

What surprised me the most as I stepped onto the Roma plaza, was the heavy smell of warm seawater mixed with something unpleasant. Coming from an island I am used to the sea smell but not with the slight additive. Thankfully I had stopped noticing it for the most part a few hours later.

Being there in May also meant that the height of the tourist season had not yet started, so while walking around the small cobble streets along side the canals I was shocked by the low number of people I would pass. However, as I went further into the center of the city, closer to the Grand canal, the population density started going up. Still, I have to battle my way through more people on a sunny day in Reykjavík than I felt were on the San Marco plaza.

The weather was fantastic (by Icelandic standards), sunny intermingled with clouds, warm with a slight breeze. Venice it seems, at this time of year, is the perfect place to go simply for getting lost in the alley ways, taking in the old structures and city life, while bouncing between cafés.

The group was large, and varied. The biggest nationality was German, at fourteen, three Italians, one Portuguese, one Dutch, and a Icelander. Even though I was meeting all of them for the first time, we all seemed to hit it off immediately. The birthday dinner was held at a rather nice Sicilian restaurant, where we occupied the center of the place on a long table. Wine, seafood and polenta was had until we headed out to the main watering hole for the locals.

The old city doesn’t have clubs, but it does have bars and plazas. So the locals gather outside, having drinks in the warm evening air, and mingling. It was at this point that it struck me how peaceful the city felt without roaring car traffic and excessive street lighting. Even with crowds of people having wine, talking and dancing, it didn’t feel overwhelming.

The next few days passed too fast, with more trips snaking around the city, checking out some of the Biannale pavilions, and even one to the beach (I never knew Venice had one).

All in all this was perhaps one of my favorite vacations in a long while, and I am sure to go visit again.

Just not during hight of tourist season!

Sun burns & sore feet

Link to album

So over the last weekend I, my two cousins and their girlfriends went on a hike in the Icelandic country side. The first weekend in August is usually reserved for festivals held around the island and involve a fair bit of alcohol. This year we decided to go on a two day hike and experience nature. The hike was somewhere around 40-45km all in all.

We decided to go first to Hólaskjól, which is a camping center at one of the entry points into the highlands. We stayed there the first night there, waking early on Saturday morning to head out. We noticed a group of Brits there, all kitted out in Land Rovers and some pretty impressive gear. I got talking to one of them and turned out they were heading deep into the highlands for the next two weeks. The cool thing was they had lots of kids with them, ranging from first graders all the way to late teens. That is going to be one cool trip those kids are going to be experiencing!

We also noticed a group of mountain cyclists, all kitted out in brand new multi colored clothing. Cycling has become quite the sport here in Iceland in the last couple of years. But I get the sense that some people take part in it due to elitism. Buying the latest and greatest gear is expensive, and old gear seems to have a stigma attached to it. It turned out I was right, as we not only overtook them later in the day but actually beat them to the Strútslaug where we stayed the night. A hiking group beating a group of mountain bikers, on rough off trail terrain. That should simply not happen.

But I digress. The first day we had clear skies, and the sun scorched us. Sun burns were had. But since we had to cross 4 rivers that day, and the water was melted glacial water we didn’t mind the sun warming us up. The terrain was fantastic, and as soon as we had reached the top of Ófærudalur (around midday) we had seen some great vistas and waterfalls. The valley it self was mostly down hill, but on rough terrain. Few hours after that we reached our camping site, Strútslaug. It has a small pond where water from hot springs mixes with water from the glacial river, creating a nice place to bathe. Beers were had, and all was good.

I took my Aeropress and grinder with me, and also brought roasted beans from Reykjavík Roasters on the trip. Quality coffee in the morning after camping makes all the difference, and puts me in the right mindset no matter the weather. And good thing as well, since later in the second day we would get pretty fierce rain for a few hours. We walked south along Hálsárlón glacial lagoon then at the end turned up the mountain ridge, along side Svarthnjúksfjöll. The incline was steep at times but it was a pleasant walk. Having good equipment is key while hiking in Iceland, as the weather can go from sunny to beating rain in an instant. And that is exactly what happened during our uphill walk.

Some of us had old equipment, which started leaking through, while I had just reinvested in new equipment earlier this summer. I enjoy walking in bad weather when using quality equipment. Protected against the elements, it feels like you are invincible and can take on anything.

At the end when we reached Hólaskjól later that day, the weather was better. Which was a good thing, seeing as we had brought with us enough food to have a feast on the last night. We grilled some lamb prime, corn on the cobs, potatoes, made wild mushroom sauce, and had red wine. After a 25km walk in one day, that was one fantastic meal. For our way back to Reykjavík, we went through Fjallabaksleið Nyðri up to Landmannalaugar, and then took Landmannaleið down passed Hekla and onto the ring road again.

While a big part of the Icelandic population had hangovers after the weekend, we had sunburns and sore feet.


Link to album

It had been a bucketlist item for some time to hike a well known route here in Iceland called Laugavegur. And so soon after coming back home from Canada, a friend offered up the possibility for finally checking it off the list. Its a easy walk, usually done in 2-3 days (a ultra marathon is held every year where the record is just over 4 hours!), and takes you through some fairly varied range of landscapes (on a Icelandic scale at least). And me not having much in the way of plans for the summer said sure.

We started at Landmannalaugar, a beautiful place where geothermic water flows out from under the lava field and creates hot pools where Icelanders have historically bathed in for centuries.

Currently it is swamped with tourists, and looks more like a refugee camp with hundreds of tents strewn about and people waiting in lines to use the limited facilities. For anyone wanting to go there and really experiencing it like it should be, I would recommend going during early spring or late autumn when regular bus trips there have stopped. Just rent a car and go have an adventure. Make sure you get a 4x4, and are equipped to hike some part of the road, since the place usually gets snowed in.


The lava field is made up of, among other types, Obsidian (or Hrafntinna in Icelandic). Which relates to the name of the campsite where we stayed for the first night, Hrafntinnusker or Obsidian Reef. It’s a barren piece of rocky plateau huddled right up next to a hill, that gives it a bit of protection from the elements.
The campsite has small walls all around, made up from rocks for wind projection. We were a bit tired when we got there, so getting the tent up felt like bit of a struggle. But once up sitting inside and cooking dinner felt great. The night was stormy, with the small walls around doing their best to shield us from most of the gale. My friend had not packed the best of gears, so she had a rather rough night sleeping on the frozen ground.

The next day we had a bit of every kind of weather. Sun, rain, snow, wind, fog. All in all rather good, seeing as this is Iceland and the likelihood of enormous amounts of rain is rather high and we only got a small drizzle. On the way we passed a Australian couple that were in Iceland for the first time, and doing mountain hiking for the first time as well. Which I found kind of crazy. To go all the way to the other side of the planet and go for a multi day hike as a first time taste. But then again, they come from a country that hosts some of the worlds most poisonous animals. Why do things half measure.

Álftavötn in the distance

We stayed at Álftavötn for the second night. It was a bit windy at the beginning but then settled down, and the sun started shining. I sat in the grass by a small river, reading and sipping some 16 y.o single malt scotch I had brought with me in a hip bottle. It was a nice and quite moment out in nature, something I hadn’t experienced for months during a long crunch time with Memento and during my stay in Canada.

Zen moment

In the morning I got rather envious of a French couple that was sitting close by, having breakfast and making coffee using a Aeropress. I own one my self, but hadn’t thought about bringing it. And after two days of instant coffee, my inner coffee snob was starting to stir (as well as my tastebuds!).

We pressed on for the third day, which was going to be our longest one or around 30km. The weather was good, and the terrain was pretty flat for the majority of the walk. We passed a group of middle aged Americans that I had noticed at the campsite the day before. They obviously were going for the more luxurious way of hiking. Gear driven between stops. Big dining tents pitched for them, equipped with a dedicated chef cooking for them. We overtook them quickly, as they moved slow enough to almost start going backwards.

During our walk we crossed a few rivers, where the high pitched shouting of American tourists could be heard kilometers away as they wade into the glacial water. The color scheme of the ground started shifting from the browns and reds of the high temperature areas we had hiked through in the past two days, and into more deep blacks and vivid greens. This would become my favorite part of the whole trip.

Black and Green

My Nexus 5’s camera couldn’t do the colors or mood justice. Black volcanic desert all around, contrasted with vivid green slopes of jagged hills all around. On top of that, slight mist. Walking in silence in that scene was extremely relaxing. It made me realize how saturated normal city life is with ambient sounds and distractions. I started wondering about the possibilities of living out in the country side, close to nature, away from all the noise. But that will be a post for another time.

Last major river

After a while we reached the last stop, usually where hikers spend the night before continuing. But we had decided to do it in 3 days, so after a short stop filled with energizing food, on we continued. By now we were low enough to sea level that there was more vegetation around, though only just. But with every hour it become thicker and thicker.

At this point we started noticing helicopters flying above. Obviously more signs of tourism, and something you would have never experienced in Iceland until perhaps two years ago. In a way it made me sad that even out here, one couldn’t fully escape modern society.

With the last of our energy, we marched through the dense forested area of Þórsmörk. It felt almost alien, after so much time spent in the barren volcanic desert. About 10 hours after starting out from Álftavötn we reached our camping area for the night. That evening I had the most delicious lamb stew I have ever tasted, as well as a rekindled enjoyment for hiking.

Super Source

A couple of days ago I read an interesting article by Pierre-Yves Ricau, an Android Software Engineer for Square, where he listed reasons for why Square has moved away from using Fragments in their Android products. In it he mentioned the ridiculous life cycle of Fragments, how it makes them at times hard to handle and even harder to test against. And I agree with him. Fragments are easy to use in smaller projects, but in my experience don’t scale linearly in difficulty as the project grows. And if you start bundling many of them together at the same time and even throw in some animation you usually have a recipe for a minor disaster.

Now a short while after reading that article I had a situation where some freshly made code came back from testing with a bug ticket attached to it. A couple of Listviews (contained inside a Fragment) weren’t being updated as new data was being stored in the local database.

Alright, I thought. Something must have gone wrong with storing the new data into the database. Maybe I just forgot to update the database with the schema. Huh, no wasn’t that. Alright, did the values actually get stored? I pulled the database and had a look.

A little side note, pulling a whole database can easily be done using ADB with the following command

adb -d 'run-as <your-package-name> cat /data/data/<your-package-name>/databases/<your-database-name> > /sdcard/<your-database-name>'

And then simply do a pull operation.

To make a long story short, the data was there, getting stored correctly and the result was handled in the manner designed. It was time to see what was happening under the hood.

Brakepoint time!

The Fragment uses Loaders, and LoaderCallbacks, to access the database and display the results to the user. Those callbacks have two overridden methods. onCreateLoader(id, args) gets called when the Loader is created through the LoaderManager, and it initializes a custom Loader with parameters telling it what data to load. This method was called, and it executed a database operation as instructed.

So far so good.

The second method is onLoadFinished(Loader, data) and it is invoked when the loader has finished (duh!). Except.. it didn’t. That didn’t make sense! Looking at the change logs I could see that nothing had changed in the implementation of the loaders, or the callbacks. Everything should have worked!

At this point I started pouring over the new code, trying to find a single reference to something that might shed a light on what was happening. After finding nothing, I checked out the latest stable build and started manually adding in the new code, testing between every addition. Finally I had copied everything over and the bug was not present! At this point I was astonished about what was happening. I could have decided that it had just been glitch in the matrix, or I could go back to my branch and find out what was actually happening.

Introducing the Rubber duck

I sighed loudly enough that a coworker noticed and asked what was going on. I went into rubber-duck-debugging mode during which he noticed that the onStart() method was calling super.onResume() instead of super.onStart(). I casually fixed it, we wondered for a second why it had compiled like that, and then resume the debugging session.

public void onStart(){
	// Code ...

public void onStart(){
	// Code ...

Turns out that this was it! It is not hard to miss this slight difference, as can be seen in the code above. And this wasn’t even part of the new code. I had no idea that there had been a change there, even though later I noticed it had shown up in the change logs (guess I focused to intently on more meatier changes).

But why had this caused my Loader to initialize, run, but not receive a response back?

Always go full source

It has been suggested that your first response to someone’s complaints about problems in the stack is to point them to the source code. And so that is what I did.

Looking at the source code for Fragments, and the onStart() method in particular, you can see that there is a flag ‘mCalled’ that gets flipped, as well as some LoaderManager initialization. If you have ever used the Android SDK you may have had an SuperNotCalledException raised at one point. And in the stacktrace you get a reference to Looking at it you can see that same flag ‘mCalled’ is used to verify, and force, that the call to onStart() passes into the default implementation at some point. If not, then a exception is raised.

Alright, now lets look at onResume(). Yes, your eyes do not deceive you. The only thing this method seems to do is to flip ‘mCalled’ to true. Why? Oh only so that performResume() may verify that you called super and throw an exception if you didn’t….. And since I did a wrong kind of super, there was no initialization of the LoaderManager and none of the Loaders got started, but by calling super.onResume() I was able to avoid getting an exception. Thus completely obscuring what had actually broken, and with no reasonable connection between the cause and the issue.

Further more if you look at that source code I’ve linked above you can see how Loaders are automatically started by the fragment as soon as onStart() is invoked. This was a problem in this same product of ours where it caused the Fragment’s entry animations to lag since the Loaders were trying to load data into the Listviews before the animation was even finished. Our way of dealing with that problem was to register an animationListener on the Fragment, and attempt to initialize the Loaders when the animation had finished. And we then had to unregister the loaders when the fragment was moved onto the backstack, since next time the fragment would be displayed the loaders would get fired up during the animation cycle and everything would lag.


So what is the point I’m trying to make here? Well, by making a slight error at one point I was able to throw a wrench into the gears in such a way that the engine worked perfectly, just not in 2nd, 4th or 5th gear. And there is no reasonable way that anybody would make a unit test that could discover this case, because all the crucial logic required for this bug to surface is ‘hidden’ in the source of the Android SDK.

So yeah Fragments are painfully unstable and fickle beasts that will become mad at you if you as much as look at them in a wrong way. I may just start mirroring what Pierre and Square have decided to do, and do away with Fragments all together in future projects, just to see if doing away with them all together is easier then living with them.