Fork us on GitHub

New Android Peer Mode

We now have an experimental new mode that allows z-ordering peers on Android
New Android Peer Mode

New Android Peer Mode

As we mentioned recently we have a new idea on how peering can be improved and we just deployed a this into our build servers in the weekend update. This is highly experimental and might crash instantly which is why we hope you give it a test drive and see how it feels before we switch it on by default.

To recap: Peers (or heavyweight components) are OS native widgets. E.g. when you use the BrowserComponent we effectively load the OS’s native webkit renderer and use that instead of showing HTML ourselves. This is good as it allows us to use OS native functionality, however it’s bad because peers have a lot of limitations which we covered in depth here.

One of the biggest limitations has been that peers are always drawn on top of the UI as they are drawn separately from Codename One. With the original implementation of Codename One which was double buffered this made a lot of sense, you can’t conceivably implement peers in any other way. However, newer implementations moved to a more dynamic architecture so we can take better advantage of hardware acceleration…​

With that we can also use this architecture to draw peers directly into the rendering graph which is exactly what we do in the new Android pipeline changes. Since this is such a huge change we left it off by default and you will need to set the build hint: android.newPeer=true.

We will remove that build hint in the future so it is undocumented in the developer guide, it’s hard to maintain that peer due to the complexity of the fork

Please try your apps with the new flag and let us know about crashes, memory leaks or problematic functionality that didn’t exist before.

This should allow a lot of very exciting functionality, e.g. features like ToastBar, glasspane, layered layout etc. will work with peer components and will allow you things like drawing on top of a map, video, browser etc.

Notice that this isn’t available on the simulator/iOS at this time so you can only see this working on Android devices. We plan to add something similar to iOS and the simulator as we move forward.

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.