Author: Mihai, last modified: 06/03/2022
On March 5h, 2022 I finally fixed a bug in Mahjong Zen that was causing the game to crash after watching an ad.
This is the retrospective of how the bug was introduced, investigated and fixed after affecting the game for more than 3 months.
Mahjong Zen contains interstitial video ads from Vungle. The ads provide revenue to suport free play. Over the past few months I heard several complains from users describing ads that "won't load" or "loading and freezing the game". The cause of those reports is unclear to me but I suspect it has to do with the browser version the users have installed locally, the status of Windows Updates or their internet connectivity. These reports were sporadic, but enough to make me look for a solution that would attempt to fix the problem.
In order to deal with the ads that won't load problem, I decided to use a timer that would attempt to display the ad, wait 60 seconds, then start a game of mahjong.
I put together a simple implementation of a 60 seconds timer.
The code looks simple enough and I decided to start testing it manually to put it to the test.
When the ad loads and completes playing the ad can be closed and the game begins. This existing behavior was still working correctly after the change.
To test the newly implemented fix I had to replicate the environment first described by the users. I prevent the local ads from being displayed and sure enough after 60 seconds the timeout mechanism would kick in and start the game.
At this point I considered the fix good and the game ready for launch. The new version was soon uploaded and in the hands of customers.
The problem is that I haven't explored all possible scenarios related to ad watching and tested creatively the implications of the timeout.
It took over 3 months to finally piece together another scenario that would cause the game to crash after watching an ad.
It turns out that some players don't just stare at the screen while an unskippable ad is playing. They sometimes do something else while the ad is playing like check their phone or refill their coffee. This scenario is the one I haven't tested and that causes the crash.
The easiest way to fix this issue is to remove the timeout "fix" that was applied in the first place. It was a hasty fix that was hiding a problem rather than fixing it and it triggered a new, more serious bug.
1st of December, 2021, the bug is release in 0.0.80.0 version of Mahjong Zen
Several attempts are done in the following released to understand the problem by adding logs and more analytics events.
5th of March, 2022 the issue is identified
5th of March, 2022 the issue is fixed
5th of March, 2022 an update containing the fixed is relased in the Microsoft Store