Hercules Unity 3D, C-Sharp, Android - Image loading optimizations

Register
Submit a solution
The challenge is finished.

Challenge Overview

 

An upcoming project is being worked on by the Hercules customer and is targeting Unity 3D to run on some VR devices.  They have requested that we build out some service classes for them targeting services that we have had access to for awhile.  We have done this service work for Java, Node, iOS, and Android, and this code challenge will extend the existing codebase to include account type services for the scheduler, which is used to manage recordings.

We have recently completed a number of core network services for this application.  The client has asked us to help now with some of the image loading optimizations, since the end application will be very image heavy.

In the forum is a sample project the client provided showing image loading working in a Unity application.  In particular, look at the XImage.cs script in Scripts/Factory in the Unity project.  

The client has mentioned that image loading is taking too long.  Each image has to be loaded over HTTP and then converted into a texture for the 3D application to use, which is processing and time intensive.

The client has asked us to make a few changes, and that's where this code challenge comes in:

Ximage

This challenge will take the XImage class and work on optimizing it with a couple different items:

  • Caching of texture data by URL
  • Optimized conversion of image data to a texture using native Android code

���Caching

After we have completed rendering of an image to a texture, we can cache the converted text data in Sqlite, similar to what we do for the services.  The key to the cache would be the URL, and the value would be the texture data.  This way, when a URL is requested to be loaded in XImage, we can check the cache first and just return the texture data if it exists, otherwise we can make the network request and build the new texture data.  The cache should have a configurable expiration for the values, to ensure that the images don't become stale.  

Native code

The final application will be targeting Android to start.  The client has recommended making the following change to see if it helps with texture conversion:  

  • Allocate a texture with Unity
  • Pass the GL handle and image URL down to native Android code
  • Make the URL request and fill the texture bits from native code
 
The texture format should be configurable, but the client has asked that we initially target one of the higher quality texture formats, either ETC2 or ASTC:

http://docs.unity3d.com/ScriptReference/TextureFormat.html

Code format and validation

You are free to change the functionality of XImage as you see fit, but please make sure the demo provided in the forum runs well on Android with the updated code.  Make sure your validation includes steps for running on Android and you test on an Android device to ensure that performance is better after your changes.  For your submission, it's fine to just include the changed files, instead of the full project, due to how big the submissions might be.  Just make sure you include a document describing how to apply any changes.



Final Submission Guidelines

Please see above

ELIGIBLE EVENTS:

2016 TopCoder(R) Open

Review style

Final Review

Community Review Board

Approval

User Sign-Off

ID: 30053389