Cppia (Faster Standalone Testing)

Justin

  • *
  • Posts: 4716
What is Cppia?

Cppia (pronounced "sepia") is a new beta feature that allows desktop games to be compiled faster. Using my favorite test case, Ghost Song, compile time went from ~40 minutes to ~40 seconds with Cppia and other recent Haxe generation improvements.


How does it work?

There are many steps to the compilation process of a Stencyl game.
- Design mode behaviors are stored as xml. They are read and transformed into Haxe code. (very quick)
- Generated Haxe code and assets are copied to the games-generated folder. (fairly quick)
- From here, the steps are a little different depending on what you're targeting. We're focusing on desktop games here.
- The haxe code, including the source for Stencyl, the haxe standard library, openfl, lime, and additional libraries we use, and your own behavior code on top of all that, is translated into C++ code. (very quick)
- The C++ code is compiled into an executable that you can run on your OS. (THIS TAKES A LONG TIME!!!)

Cppia is a way of speeding up the process. How does it work? Cppia divides the program into two parts: A host application and a script.

The host application is compiled C++ code, so it can be run on your OS, and has high performance. The host is made up of all of the parts of an application that don't change very often, and parts that are critical to performance, such as physics engines. In stencyl-cppia, the host is made up of almost everything except for the code you generate with design mode behaviors.

The script is not compiled C++ code. Instead, it's a plain text format that the host application can interpret. This means that, at the cost of losing highly efficient compiled code, we can have much quicker "compile" times for our games.

Since a huge amount of code is now compiled only once, in the host application, there's no need to worry about compiling all that framework code again when you test a new game. The only thing that will be "compiled" is the code from your behaviors, and it'll only be translated into a text format that the host understands, which is much faster than traditional compiling. The big drawback is performance, but since we place most of our performance-critical code into the host application, you only have to worry about performance drawbacks in your own behaviors, not in the engine.


How do I use Cppia?

(This step no longer required with the latest builds)
- Download the latest build (b8627, September 1) and set the cppia.enabled flag in [workspace]/prefs/boot.txt.
Code: [Select]
cppia.enabled=true
- Test a game in Stencyl with the "Cppia" target.


===== Feedback =====

This feature is still in beta, and there may be differences between a full native game and one run with the Cppia target. Please report any such differences or anything that causes a crash in cppia but not on desktop.

For now, this is a desktop-only feature, but in the future, we plan to also allow mobile games to be exported with Cppia.

« Last Edit: November 02, 2016, 02:42:28 pm by Justin »
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Donni11

  • *
  • Posts: 2181
Wow !!!!! Amazing :) !!!
Will Stencyl pre-enable this feature in the upcoming releases ?
Peace

Justin

  • *
  • Posts: 4716
Eventually, when we've got enough feedback. Perhaps we should have enabled it by default even for this release. Probably by next one.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Donni11

  • *
  • Posts: 2181
Also is Cppia only for testing ? Because there is no publishing tab for Cppia only a testing option.
Peace

Justin

  • *
  • Posts: 4716
It's meant only for testing. You still get the best performance with a full desktop compile, so that should be used when you're ready to release a game, or when you want to send the game to others for testing.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Donni11

  • *
  • Posts: 2181
Also I noticed in the boot.tx  that preview browser in disabled , what is it ?
Peace

gianmichele

  • Posts: 52
Does Cppia allow hot reloading of resources and scripts? That would be fantastic!

Imagine sending the updated game to a mobile device via wi-fi and see it reload on the fly.

Justin

  • *
  • Posts: 4716
It does, but I've only seen it used to reload the game as a whole. It would certainly be interesting to see if we could get it running on a behavior-by-behavior basis.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

ajimundi

  • *
  • Posts: 230
I take it the  first compile will still take a long time? Would the host be compiled once for all game or individually? Lastly, do we need to erase something if stencyl is upgraded, which may result in host becoming obsolete?
::: It's never too late, unless you're dead. Maybe not even then. :::

Justin

  • *
  • Posts: 4716
The host is compiled just once, and then works for all games. This will take a long time, and happens automatically the first time you try to test.

When you update stencyl, you can use Debug > Cppia > Rebuild Cppia Host to make sure you pick up any updates in the host.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

1MrPaul1

  • *
  • Posts: 1285
Great Justin.

Hope you will fix all issues in desktop soon as long as it is most promising platform now.

danielle53

  • *
  • Posts: 55
Hi,
my prefs/boot.txt is replaced when I start Stencyl. I have to use a temporary write permission  on it in order to
set  my preferences..
  • debug=true, 
  • cppia.enabled=true
  • html5.enabled=true
Needless to say that I've got a warning about it
Code: [Select]
Level:     ERROR
From:      stencyl.sw.Session
but at first view, no problems with the compilation of cppia itself

« Last Edit: September 02, 2015, 05:22:05 am by danielle53 »

yoplalala

  • *
  • Posts: 1632
Indeed on windows 8.1,

everytime you open Stencyl it overwrites boot.txt so you cannot modify preferences.

Justin

  • *
  • Posts: 4716
So you have to sign in again every time you use Stencyl?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

yoplalala

  • *
  • Posts: 1632
humm sorry it was my fault ...

but ccppia doesn't work for me when it works on windows.

Normally compared to desktop export, it should later switch scene, the load a saved game, but it crashes instead.

I think it doesn't work
with the block "switch  to scene and slide up"