News for hackers. Stuff that matters.
Re:Android: Faster emulator with better hardware support by hub_ on Monday April 09, 2012 @03:05PM (#3818638)
They should use the iOS Simulator approach: have the whole "emulator" build native on the host PC instead of running the ARM version in qemu.
Re:Android: Faster emulator with better hardware support by com2kid on Monday April 09, 2012 @03:39PM (#3818816)
There are different trade offs for each technique. Aside from ensure that native code functions properly (e.g. Android NDK), you can get platform specific perf metrics from an emulator that you just do not get from running x86 code.

With Android apps running in a VM this is not as much of an issue, but it is still nice to have.

The downside is that writing performance emulators for 1ghz+ multicore ARM chips is hard. :) GPU virtualization helps out a fair amount with this.

As an aside, they do have a virtualized mode that appears to be sort of a hybrid between an emulator an Apple's technique. I believe they are still running the entire Android OS, but it is a native x86 version of it so you get much better performance.

The other cool part about having an emulator is that once your emulator is complete enough, you can add in emulation support for all sorts of sensors, GPS, etc, and they are truly emulated and the programmer can interact with them the same way they would on the device (with the need for some sort of "feed arbitrary input" code paths of course).

When you just have a glorified UI toolkit that has been ported to the Desktop, everything else (GPS, sensors, etc) can end up special cased.

Re:Android: Faster emulator with better hardware support by drewcrawford on Monday April 09, 2012 @05:10PM (#3819247)
As an iOS dev, I can tell you, I would much rather be doing my perf optimization on real hardware than on an emulator, even one that emulates clock-for-clock (and I highly doubt that the Android NDK does, although perhaps they ship a tool that lets you extract this information).

Just for starters, if I am profiling code, it's probably because the code is slow. (Infamously, for awhile we had a 13-hour unit test). If a quad-core 1ghz ARM device is slow, the last thing I want to do is throw an emulator into the mix.

Re:Android: Faster emulator with better hardware support by nekitamo on Monday April 09, 2012 @08:13PM (#3819991)
The binaries built by the Android NDK are emulated on the emulator properly. I've deployed NDK binaries on the emulator and traced it with IDA Pro, one line of ARM assembler at a time... So yes, it's a proper emulator.

Just a fact I thought you might find interesting.

Re:Android: Faster emulator with better hardware support by drewcrawford on Monday April 09, 2012 @09:32PM (#3820246)
But does an ADD instruction on ARM take the correct multiplier of time as the MUL instruction? No, because time-accurate emulation is shockingly hard. Further reading:

http://arstechnica.com/gaming/news/2011/08/accuracy-takes-po...

Re:Android: Faster emulator with better hardware support by hub_ on Monday April 09, 2012 @05:19PM (#3819292)
Performance testing in any case has to be done on the target device. Neither iOS Simulator nor the Android Emulator are appropriate.
Re:Android: Faster emulator with better hardware support by com2kid on Monday April 09, 2012 @08:25PM (#3820025)
True enough, but aspects like memory consumption can still be tested on an emulator. Due to differences in x86 and ARM code gen, it can be beneficial to get actual numbers.

There are also aspects like ease of automating. An emulator running on a desktop is easier to fiddle with than an actual device.

Re:Android: Faster emulator with better hardware support by m_eiman on Monday April 09, 2012 @05:01PM (#3819213)
There are different trade offs for each technique. Aside from ensure that native code functions properly (e.g. Android NDK)

How about running dalvik in x86 and just emulating NDK calls? Should give a nice speed boost while still supporting native ARM code.

Re:Android: Faster emulator with better hardware support by mdwrigh2 on Monday April 09, 2012 @03:56PM (#3818901)
The problem with the simulator approach is then you have to make sure all of the APIs behave exactly the same both on the desktop and the phone (which are running two different processors). This certainly causes some issues (the Simulator has had no end of trouble with the sound APIs in the last 6-12 months, and only recently has it even allowed me to play sounds, albeit while still throwing exceptions, for example).

On top of that, Apple only has to worry about being consistent on two platforms: OS X and the device (iPad, iPhone, etc.), whereas Google supports all three major platforms (Win, OSX, Linux) and doesn't control the underlying hardware.

Re:Android: Faster emulator with better hardware support by hub_ on Monday April 09, 2012 @05:12PM (#3819257)
it is not like they support it correctly in one single platform. Also it is not like the problem isn't relevant with using QEMU, it remains relevant.
Re:Android: Faster emulator with better hardware support by mdwrigh2 on Monday April 09, 2012 @05:17PM (#3819280)
> it is not like they support it correctly in one single platform.

I'm not sure what you mean by this. Example?

>Also it is not like the problem isn't relevant with using QEMU, it remains relevant.

Which problem? Being consistent across multiple platforms? QEMU is fairly good at this.

When I say there are problems with the simulator, I mean like the whole audio api wasn't working on the simulator for awhile. This isn't a small difference, this made it so that I couldn't even test the app. (Not to mention the other hardware support I needed, accelerometer/gyroscope data, wasn't supported either).

Re:Android: Faster emulator with better hardware support by nextparadigms on Monday April 09, 2012 @03:10PM (#3818666)
Isn't that what the article says, too?

"Last week’s r17 developer tools release included x86 system images and host drivers (available through the SDK Manager), allowing the emulator to access the host CPU natively and offer significantly faster execution."

I just wonder, does this mean that the apps built on this version will only work on x86 devices and you need to modify the app later to work on ARM devices, too? Because if that's the case I probably won't bother with this, since 99.9% of Android units have an ARM chip.

Re:Android: Faster emulator with better hardware support by njs12345 on Monday April 09, 2012 @03:18PM (#3818701)
Almost certainly not --- Android apps are compiled to a platform independent bytecode anyway, so there's no reason the compilation process would be any different here.

See http://en.wikipedia.org/wiki/Dalvik_(software)

Re:Android: Faster emulator with better hardware support by daeken on Monday April 09, 2012 @03:20PM (#3818717)
That's only true of apps written for Dalvik. Applications using the NDK are arch-specific.
Re:Android: Faster emulator with better hardware support by psquid on Monday April 09, 2012 @03:19PM (#3818708)
Nope. Android apps are, with one caveat, independent of any particular architecture, due to their Java/Dalvik base.

The only situation where anything developed on x86 would not also work on ARM is if you include native code via the NDK (which is not usually done except where you need to wring every last bit of performance out of the device), and that's just a matter of building the native code for all the platforms you intend the app to run on.

The platform used by the emulator image makes no difference to any of that, it just makes it a lot more practical to get usable speed out of it.

Re:Android: Faster emulator with better hardware support by huggyface on Monday April 09, 2012 @03:30PM (#3818767)
which is not usually done except where you need to wring every last bit of performance out of the device

I think that's overstating it a bit. The NDK is very heavily used by the overwhelming majority of premium games, not least because it allows for significant code reuse between Android and iOS. The release of the NDK was the beginning of a massive quality app explosion on the platform.

Re:Android: Faster emulator with better hardware support by ryanpetrich on Monday April 09, 2012 @03:21PM (#3818720)
It's still running the Android flavour of the Linux kernel along with all its various processes inside of a VM. iOS Simulator runs SpringBoard, the various iOS daemons, and any user apps as native processes on the host OS X system. The difference may be negligible though.
Re:Android: Faster emulator with better hardware support by huggyface on Monday April 09, 2012 @03:22PM (#3818726)
Aside from the managed bytecode, when you build with the NDK you can target multiple platforms in the same APK.

e.g. (in the Application.mk)

APP_ABI := x86 armeabi armeabi-v7a

This app will run with gust on any of those platforms.

Re:Android: Faster emulator with better hardware support by varunsaini on Monday April 09, 2012 @03:07PM (#3818646)
Maybe they tried that. but Apple had patent on that.