Showing posts with label mobile. Show all posts
Showing posts with label mobile. Show all posts

Tuesday, 22 April 2008

Mobile development with .NET CF

It's been a few days since the last posting, I've been meaning to jot down some notes from the workshop at Microsoft (Reading Uk, 16-April-2008) before anything gets forgotten:

The aim of the workshop was to discuss the use of the Microsoft .Net Compact framework for mobile application development - including performance issues and technology features. This was in the context of both our existing Java mobile applications and choosing suitable technologies for new projects.

Java ME J9 6.1.1 performance evaluation:

To illustrate the performance we'd experienced with out Java ME applications, we demoed our existing Java ME application running on IBM J9 CDC ppro1.1 on an IPAQ. The response was actually very positive. It was suggested that re-implementing it in .Net would not yield any worth while performance gains but it would most likely create a different set of problems to solve.

We ran our app with JIT enabled, noverify and nolinenumbers but it was not compiled as a JXE on this occasion. Focus was on running application performance as perceived through the GUI (user perceptions), we did not delve into profiling information. We did not look into start up times, which are roughly similar for both Java and .Net VM based technologies.

.Net CF:

.Net CF does provide some benefits, in terms of integration with the Windows operating system (integration with the Windows menu bars etc) that would be worth bearing in mind for future projects. Specifically, notification of docking events could prove very useful in some situations. Native code is supported, as external libraries (not within the assembly) but hooks into the OS API are possible by declaring them within the .Net assembly.

Versions / dependencies:

For .Net development some care regarding versions and dependencies should be considered, for example whilst versions of Windows Mobile from 5.0 onwards _should_ support any version of .Net CF, the same can not be guaranteed for the more variable CE, where platform vendors could load a CE image missing key components required for installing .Net CF. In this scenario it would be important to discover this and engage with the customer and platform vendor to negotiate shipment of hardware with the right image components installed.

.Net CF versions:

  • 1.0 -> Old original version, no longer targeted by most development
  • 2.0 -> Good baseline with significant improvements (including performance) over 1.0 (required MS VS 2005 IDE to develop).
  • 3.5 -> Current latest version (required MS VS 2008 Pro IDE to develop).

Windows Mobile versions against their CE base:

  • WM 2003 'Ozone' -> CE 4.20
  • WM 5.0 'Magneto' -> based on CE 5 (shipped with .NET v1.0 SP2)
  • WM 6 .0 'Crossbow' -> based on CE 5.2 (shipped with .NET CF v2.0 SP2 )
  • WM 6.1 -> CE 5.x ? TBA
  • WM 7.0 'Photon' -> CE 6.0? TBD

The next major version of Windows Mobile is anticipated in 2009, but no official details were given. General information suggests a planned release of Windows Mobile 7 in the 2nd half of 2009.

CE 6.0 removes the 32 process and 32Mb restrictions:
  • The 32 process limit raised to 32,768 processes.
  • The 32 megabyte VM limit raised up to 2GB of private VM is available per process.

Technologies:


Microsoft SQL Server 2005 Compact Edition is available (shipped with WM 6.0). This can be used stand alone, or connected to a server side SQL server. Can be synchronised with server DB over network. Async and synch operation is possible. Loads in process as a dll (therefore doesn't use any precious process slots, but of course it will consume RAM/processor). This is a very cut down DB, things such as triggers and stored procedures are not supported.

Ajax, DOM, Javascript is possible in the browser technology (from WM 6.0 onwards).

XML is supported - recommended to use XML readers not full blown XML DOM for efficiency reasons.

XSLT - it was not clear weather XSLT was supported on the platform, either in the browser or as .Net libraries.

Windows Mobile limitations (until WM 7.0):
  • 32 process limit
  • 32Mb memory limit

Windows Mobile can close applications when it starts to run low on resources - so applications should be developed with this in mind. The OS will pick the lowest application in the Z-order that is inactive. Notification events are sent but if the application doesn't respond gracefully it could receive hard termination!

.Net development tools:

Visual studio is the only supported option (no free express version for CF 3.5 available at this time).

Optimisation tools were not generally recommended - they advocate letting it run 'as-is' but rather to concentrate efforts on getting the design right.

It was admitted that profiling tools were somewhat weak at the moment - but this is an area they are actively addressing.

Code signing:

We were warned that some platform vendors have removed the root CA from the device, which means that the only option for getting the application code signed would be to go through the device vendor (this is something that would need to be highlighted and planed in early in the project).

Testing:

The need for thorough and extended testing was highlighted. Mainly due to the additional use cases that can occur on a mobile platform that are less likely or non-existent on a traditional desktop pc system, for example:

  • Memory cards being removed
  • Wireless signal poor / dropped
  • Flat battery, battery removal
  • Unexpected key presses from special function keys on the device

.Net configuration:

It's possible to configure the platform .Net CF using a configuration file:

http://msdn2.microsoft.com/en-us/library/bb629366.aspx

Software updates:

Whilst there is no application support for software updates (apart from the M ) there are some software components that can be used as a basis for providing this, the Mobile Client Software Factory and the Mobile Updater.

http://www.microsoft.com/downloads/details.aspx?FamilyID=F9176708-9F57-4C0F-97FB-F9C65A9BBF22&displaylang=en

http://msdn2.microsoft.com/en-us/library/bb629366.aspx

Additional links and info:

Mobile Dev centre http://msdn2.microsoft.com/en-gb/windowsmobile/default.aspx

Application developer consulting service http://www.microsoft.com/uk/adc

Libraries and widgets:

Mobility Marvels: http://msdn2.microsoft.com/en-us/windowsmobile/bb250537.aspx

Mobile Controls: http://www.asp.net/mobile/

Monday, 14 April 2008

.NET CF

Some quick prep /initial prep / background reading for the workshop with Microsoft at their Reading Campus.

Latest version is currently 3.5 (3.5 RTM 3.5.7283.0 - 2007-11-19)

Overview of 3.5 features http://searchwindevelopment.techtarget.com/news/article/0,289142,sid8_gci1285069,00.html

You can determine the installed CF versions by running /Windows/cgacutil on the device (several versions can be co-installed without issue).

CF 3.5 goes hand in hand with Visual Studio 2008 (whereas the older 2.0 was paired with VS 2005).

Java ME JSR 216

Progress! This morning I was able to make some small changes that made a massive difference to the GUI performance of the Java ME client version of one of our products. So, I thought I'd take a moment to write up some notes on it and Mobile development in general:

Basically, in doing some testing and profiling previously, it had become evident that one of the main performance problems in JSR 216 GUI was the use of layout managers in GUI construction (especially the GridBagLayout!). I'd previously addressed all other obvious performance hot spots with optimization or re-implementation - and knew that Layout managers where one of the remain areas to re-factor. All of our GUI components were lightweight and some custom handwritten to perform a specific task. It was tempting to use SWT but wanted to keep the solution generic and AWT/LW based if possible.

Well, after identifying a spurious GridBagLayout that wasn't strictly necessary I was able to re-factor the code to remove it. The impact of this one change has been massive, with something around a 2x to 3x performance speed up and a much more responsive GUI! This is a great return for the effort involved and extent of the change.

One area that still remains is to either implement or port a StringBuilder type class to the JSR 216 platform for faster string concatenation. JSR 216 only supports StringBuffer, while this might not be a problem in most scenarios, some of the custom transparent lightweight widgets I'd written for the product need to do a lot of strings building, so it's performance is critical.

A little digging around has yielded these interesting links that I need to investigate a little more at some point:

Javolution:

http://javolution.org/ - which contains a Java ME library with a fast string builder class (and many other fast classes!).

String builders:

This implementation of a string builder http://www.tailsweep.org/utils/xref/org/tailsweep/utils/builders/StringBuilder.html

RetroWeaver:

and also Retroweaver http://retroweaver.sourceforge.net/ looks interesting. This would enable Java 5 for the mobile platform. However, I have some reservations, mainly todo with issues of performance (Mobile code tends to need to be tight and optimized for the platform). This could be a major win for porting existing code though, well worth keeping in mind.

ProGuard:

I'll also mention that for Java ME development, utilising ProGuard http://proguard.sourceforge.net/ has given noticeable improvements in performance on mobile platforms (as well as smaller Jars).

A word of warning, make sure the end product is tested thoroughly after optimising. Aggressive optimisation can change sometimes change expected functionality - be careful!

--
LW-VCL:

One other thing I came across, that I'm interested to evaluate from a performance perspective, possibly against SWT is the Java LW-VCL, which looks really quite good http://www.lwvcl.com/