Latest posts from Codename One.
Blog

ParparVM Optimizations: Java on iOS now 2.8x Faster
TLDR: ParparVM is now up to 2.8x faster, and produces binaries that are 15%-20% smaller than before. If you build your app for iOS today, you may notice a performance boost due to some improvements to ParparVM – the AOT compiler we use to build Codename One apps for iOS. Read on for a short history of ParparVM, as well as some details about these improvements. A Brief History Of ParparVM In the beginning, Codename One used XMLVM to build apps for iOS. It worked by converting Java byte-codes into its own XML representation, and then converting that XML into C-code. Unfortunately XMLVM was an academic project, and was announced in 2014 that development on it would be discontinued. We were faced with a choice. Do we continue to use XMLVM and simply support it ourselves, or do we migrate to something else. At the time RoboVM was an exciting new technology that compiled Java to LLVM and could produce iOS apps. I had also created a proof of concept port using Avian, an AOT compiler for Java that could produce iOS binaries. A fourth option, which seemed overly ambitious at the time, was to create our own tool from scratch. Ultimately, that is the avenue that was chosen, and ParparVM was born. ...

TIP: Use iOS CocoaPods Dependencies in Native Code
Editor note: This post is still valid for CocoaPods, but current iOS dependency setup also supports Swift Package Manager (SPM). See the current “Working with iOS” section in the developer guide. Last week I talked about using gradle dependencies to build native code, this week I’ll talk about the iOS equivalent: CocoaPods. We’ve discussed CocoaPods before but this bares repeating especially in the context of a specific cn1lib like intercom. CocoaPods allow us to add a native library dependency to iOS far more easily than Gradle. However, I did run into a caveat with target OS versioning. By default we target iOS 7.0 or newer which is supported by Intercom only for older versions of the library. Annoyingly CocoaPods seemed to work, to solve this we had to explicitly define the build hint ios.pods.platform=8.0 to force iOS 8 or newer. ...

Questions of the Week 42
This weeks update will go out a bit late or maybe even tomorrow. The reason for the postponing is the scope of the changes. We’ve made a lot of changes to ParparVM and we are very concerned that there will be regressions. So we would like this update to go in later in case we need to revert that work. Steve wrote a detailed post about the changes he made to ParparVM which we will post next week… ...

Moving to 64bit by Default
When building an iOS debug version of the app we only build a 32bit version to save build time. Otherwise the build will take almost twice as long as every file would be compiled twice. This worked well and was also fast enough. However, Apple started sending warnings to old 32bit apps and mistakes our apps as such. The crux of the issue is Apple forcing developers to support 64 bit, we already support it and have for years. But now Apple is showing a warning on apps built without 64 bit support even if they are only meant for debug. ...

Autosizing, Add All & iOS Redirects
One of the common requests we received over the years is a way to let text “fit” into the allocated space so the font will match almost exactly the width available. In some designs this is very important but it’s also very tricky. Measuring the width of a String is a surprisingly expensive operation on some OS’s. Unfortunately, there is no other way other than trial & error to find the “best size”. ...

Block Copy/Paste & Faster Performance on iOS
I discussed both of these last week but we’ve made some progress that warrants a dedicated post. We added a new feature that allows you to block copy & paste on a text component either globally or on a case by case basis. This is helpful for highly sensitive applications. This feature was previously restricted to Android but is now available to iOS as well with no change required to your code. ...

TIP: Use Android Gradle Dependencies in Native Code
Integrating a native OS library isn’t hard but it sometimes requires some juggling. Most instructions target developers working with xcode or Android Studio & you need to twist your head around them. In Android the steps for integration in most modern libraries include a gradle dependency. E.g. we recently published a library that added support for Intercom. The native Android integration instructions for the library looked like this: Add the following dependency to your app’s build.gradle file: ...

Questions of the Week 41
We are releasing a small Eclipse update today, it’s small because it isn’t a full release that includes the latest features/libraries but rather a minor bug fix to the previous release which was missing the UWP build target. One of the biggest changes this week is the fix for the build performance issue mentioned below. It might also speed up general app performance for some use cases! The biggest change this week is the support for peer component Z-ordering on practically all platforms, this completely changes the use cases for Codename One and we intend to take full advantage of these new capabilities moving forward. ...

Intercom Support
We use intercom.io for our website support system you can see it as the chat button on the bottom right of the page. The true value of this tool is in it’s ability to deliver a unified interface everywhere, normally this stretches into native mobile apps as well. As a result we decided to port the native intercom device API to Codename One so it will be easy to deploy everywhere. ...

Disable Screenshot, Copy & Paste
Continuing our security trend from the past month we have a couple of new features for Android security that allow us to block the user from taking a screenshot or copying & pasting data from fields. Notice that these features might fail on jailbroken devices so you might want to check for jailbreak/rooting first. Blocking screenshots is an Android specific feature that can’t be implemented on iOS. This is implemented by classifying the app window as secure and you can do that via the build hint android.disableScreenshots=true. Once that is added screenshots should no longer work for the app, this might impact other things as well such as the task view etc. ...

Strong Android Certificates
When Android launched RSA1024 with SHA1 was considered strong enough for the foreseeable future, this hasn’t changed completely but the recommendation today is to use stronger cyphers for signing & encrypting as those can be compromised. APK’s are signed as part of the build process when we upload an app to the Google Play Store. This process seems redundant as we generate the signature/certificate ourselves (unlike Apple which generates it for us). However, this is a crucial step as it allows the device to verify upgrades and make sure a new update is from the same original author! ...

TIP: Use Tethering to Simulate Slow Network Connections
I recently had to debug some code on Android Studio and was reminded how awful that IDE really is. IntelliJ is a pretty good IDE but Android Studio is remarkably slow even for trivial projects… One of the things that make it slow (besides RAM usage) is the approach of downloading everything it needs dynamically. This might be unnoticeable on Googles fast networks where this probably runs instantly. But on my fast home network this was painfully slow. ...