Tuesday, May 26, 2015

Chaos update notes

A few weeks ago I released a new version of Chaos that had what looked to be some pretty bad bugs. In fact the bug was just that the controls were enabled when the CPU is moving or casting, but you could really mess things up by tapping the screen during their turns.

This bug came about because I'd switched over to the latest emscripten build for the Javascript version.

As you may recall, I had to make some changes to the code structure of Chaos to avoid busy-loops deep in the guts of the game. Emscripten previously required you to have just one "main loop". Since then, Emscripten has gone completely insane - in a good way. The latest emscripten releases have a way to compile C code down to an emscripten-specific byte-code, that is then run on an interpreter, which itself runs in the Javascript interpreter in the browser!

What this marvellous change means is that the one-main-loop restriction is lifted. You get better performance if you write code to use the preferred way, but the interpreter-byte-code solution lets you keep the old semantics going if you don't mind taking the performance hit. Hurray! So I reverted Chaos back to how it was in release 1.18 more or less. That means no more co-routines to get around the loop restriction, and the code is easier to read and understand.

As a side effect, I added the previously-mentioned game destroying bug by enabling controls in the "wait" code that was called everywhere. The fix was easy - just remove the control polling/updates in the wait. But it broke the game for a lot of people :( To try and prevent this from happening again, I've created a beta group on Google+ and I'll push updates here before making them live to everyone.

I currently have 1 bug on my list - fix the glitched screen that happens after you minimize the game and return to the homescreen, then go back to the game. I'm doing something wrong in the Android lifecycle and the GL screen is not reset correctly.

Saturday, September 20, 2014

Running Android apps in Chrome is great for developers

This week @vladikoff released a tool that builds on Google's own Android-apps-on-ChromeOS work to allow anyone to run Android applications in Chrome on Linux! I've tried it out on Xubuntu 14.04 and it works quite well. With a few tweaks this is a better way to test applications than the slow Android emulator.

Unfortunately this doesn't work in Chromium - currently version "37.0.2062.94 Ubuntu 14.04 (290621) (64-bit)" - but did work in the latest Chrome for Linux (Version 37.0.2062.120 (64-bit)).

After installing Chrome from the official Google download site, here is how I installed ARChon:

sudo apt-get install npm nodejs-legacy
sudo npm install chromeos-apk -g
wget https://bitbucket.org/vladikoff/archon/get/v1.0.zip
unzip v1.0.zip
Then load the unpacked extension as shown on the archon page.

While most news has been about running Flappy Birds or whatever other app (try Pixel Dungeon), as a developer I was interested in debugging my own Android apps. To do this I needed to install these apps first.

It's actually pretty easy to install an APK - first create a manifest and the extension structure. For Chaos I do this:

chromeos-apk -a ~/projects/chaos-portable-build/android/port/android/bin/chaos-debug.apk
Then from within Chrome, load the unpacked "extension" (ie. the Android app/game) the same way as the main archon runtime. It'll appear on the chrome://extensions page.

App as a extension in Chrome
Running your own APK may work.. or maybe it has a few problems. In order to debug things you should add enableAdb in the manifest.json file, in the arc_metadata section:

"enableAdb": true,
enable adb in manifest.json
After clicking Reload on the extensions page you can run adb logcat and see the output of your app. This may help you find out why it crashes so much. Heh.

Some things I've found are that NDK works if you compile for x86, but the GLES emulation has a few niggles. For example GL_EXTENSIONS reports that the runtime supports GL_OES_draw_texture but when I used glDrawTexiOES it crashed. Also I disabled some GL capabilities that the game doesn't use, but as the runtime doesn't support these capabilities it also crashed.

Finally, in another app I'm making, I noticed that sharing has a few buglets. On a regular Android device you can request information about an intent to share data like this:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
ResolveInfo info = getApplicationContext().getPackageManager().resolveActivity(shareIntent, 0);
When no application to share with is available for "text/plain" then it returns null. On ARC it returns an object, but the info.resolvePackageName is null. There are probably a load of small interoperability bugs like this, which is why this wasn't officially released by Google yet.

Either way, this is a great way to test out Android apps if you don't have a phone handy. It's much better than the emulator, finally approaching the simulator approach that everyone has been clamouring for. Get it now before the lawyers at Google send Github a DMCA takedown notice ;-)

Wednesday, September 10, 2014

Toggle Javascript Enabled in Firefox for Android

The add-on for Firefox that I mentioned last time is finally available on the Mozilla add-ons site. This adds a enable/disable JavaScript toggle option to the Tools menu on Firefox for Android.

Screenshot of JavaScript toggle in the Tools menu

The code is on github if you want to see how to make a simple Firefox Add-on. It took me longer than it should have to write this, as I had trouble finding documentation on the technique to read/write a global preference. The code (in JavaScript, ironically enough) is about 120 lines. Only 30 of those are really the meat of the add-on.

Comments and ratings would be helpful. I use this add-on every day to save on bandwidth and battery. The one feature I may add is to have the page reload when you enable JavaScript again, but even that might be too much feature-creep.

Saturday, August 30, 2014

Summer 2014 Roundup

Crikey, I've not posted here for a while.

Since the last post 6 months ago here's what I've been up to, in no particular order:
Apart from that, I have recently become a member of the flock of sheeple using a smartphone/NSA-tracking-device after I purchased a Moto G 4G and hooked it up to a massive 100Mb (count 'em) per month data plan. I checked the previous few months' usage on my 2005-era Nokia phone and it was costing me about 1€ per month in SMS messages, and I only sent 3.

For the same price (1€ per month) I got a pre-paid data plan on Simyo here in Spain, and with internet-based messaging apps I can send all the messages I wanted at no additional cost. I had to pay about 10€ up front for a new micro SIM, but it came with 10€ of pre-paidness anyway. The only bummer is that I could have achieved the same 100Mb deal for free from our ISP, but they only give out a 2nd mobile line to new customers. Apparently if you're an old-time customer and threaten to cancel they'll give you the 2nd line, but I'm worried they'll call my bluff!

The reason I mention all this is that having now used an Android device as a phone daily, rather than just having it at home in WiFi-only mode (I'm looking at you HTC Magic and your 4-hour battery life), has made me think of a couple of things that I could code up.

The first is a native Android application, a boring one with nothing to do with games. There are enough games on Android already, right? The second thing is a tiny Firefox-for-Android addon to disable Javascript, which I think should have been in this mobile Firefox by default anyway. The former needs a bit of polishing still, while the latter is in the queue at Mozilla Towers awaiting review.