Thursday, October 23, 2014

Xamarin studio debugger bug - doubles have same value but are not equal

Recently I had a bug in my C# library that was hard to find due to the bug in Xamarin debugger. Problem was in the "Watch" window that showed String (rounded) representation of a double value, instead of showing all decimal digits. As you can see in the picture below, sideProductSum and diagonalProduct are both 16 but somehow they are not equal:


Here is the same method debugged in Microsoft Visual Studio (doubles shown correctly):


Tuesday, October 21, 2014

JavaFX TextField always returns empty String.

Today I worked on JavaFX fxml application and found unusual bug. This application has multiple tabs with many TextFields in each tab. While testing, one of the TextFields always returned empty String when using getText() method. It was very very confusing for me at the moment, but eventually I found out what was the problem. I accidentally gave the same ID to two TextFields in the different tabs. Debugging this was a challenge because I assumed that Scene Builder 2 would informed me if something like this happened.
So if someone encounters similar problem, check your IDs first.

Sunday, October 5, 2014

Cyanogenmod battery problem

A few days ago I wrote about how I fixed Huawei Y300. I must admit that I like Cyanogenmod very much. It's much faster and stable than stock Android that came with the phone.
But after first day of use I've noticed that battery life was terrible. In settings I switched the battery indicator to percentage (Battery status style > text) so that I can get better insight of battery consumption. Every couple of minutes battery went down for 1%. I checked the settings again and switched display brightness to Auto. Battery consumption seamed unchanged.

Then I googled it. After some search I found out that you need to re-calibrate battery after installation of new Android rom. I found this app called "Battery Calibration" that claims to do just that:
Calibration needs to be done after flashing a new ROM, but you can calibrate any time you think your battery is miscalibrated. This program does it by removing the batterystats.bin system file. The OS generates a new clean batterystats file soon, thus any fake information from the previous ROM is removed.
It's suggested, but not necessary, to let the phone fully discharge after calibration, then charged to 100% without break.
App is very simple. Just charge your battery to 100% and then press "Battery Calibration". After that you should fully discharge your phone.



After I calibrated battery it got better. Phone was with WiFi on for about 30 h without charging and it's now at 62%. So far so good.

Update: after the calibration battery lasted for 72 h 36 min. WiFi was always on, I made approximately 10 shorter calls and browsed the Internet for 3 h.