Skip to main content

News

Topic: neoSphere 5.9.2 (Read 525313 times) previous topic - next topic

0 Members and 27 Guests are viewing this topic.
  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2055
Proof of concept:
Code: [Select]
C:\src\spectacles-i>cell && ssj dist
Cell X.X.X Sphere packaging compiler (x64)
the JavaScript-powered build engine for Sphere
(c) 2015-2017 Fat Cerberus

setting up Cellscript environment...
evaluating '$/Cellscript.mjs'...
   W: no existing files match 'lib/*.js'
building targets...
   installing '@/scripts/main.js'...
cleaning up old build artifacts...
writing Sphere manifest files...
0 error(s), 1 warning(s).
SSj X.X.X Sphere JavaScript debugger (x64)
the powerful symbolic JS debugger for Sphere
(c) 2015-2017 Fat Cerberus

starting 'C:/src/spectacles-i/dist/'... OK.
connecting to 127.0.0.1:1208... OK.
establishing communication... OK.
querying target... OK.
    game: Spectacles: Bruce's Story
    author: Fat Cerberus

=> # 0: function() at @/scripts/main.js:6
6 RequireSystemScript('persist.js');

@/scripts/main.js:6 function()
(ssj) l
      1 /***
      2  * Specs Engine v6: Spectacles Saga Game Engine
      3   *           Copyright (c) 2017 Power-Command
      4 ***/
      5
=>    6 RequireSystemScript('persist.js');
      7
      8 const from     = require('from'),
      9       Console  = require('console'),
     10       Delegate = require('delegate'),

@/scripts/main.js:6 function()
(ssj) c
=> # 0: function() at @/scripts/gameDef/statuses.js:497
497                     debugger;

@/scripts/gameDef/statuses.js:497 function()
(ssj) l
    492         // cycle.
    493         specsAura: {
    494                 name: "Specs Aura",
    495                 tags: [ 'special' ],
    496                 beginCycle: function(unit, eventData) {
=>  497                         debugger;
    498                         var vit = Game.math.statValue(unit.battlerInfo.baseStats.vit, unit.battlerInfo.level);
    499                         unit.heal(0.25 * vit, [ 'specs' ]);
    500                 }
    501         },

@/scripts/gameDef/statuses.js:497 function()
(ssj) _
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: miniSphere 4.8.4
Reply #2056
Spheerus the (Code) Destroyer

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2057
That could be a good name for a minifier, if nothing else. :)
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Rhuan
  • [*][*][*][*]
Re: miniSphere 4.8.4
Reply #2058
That could be a good name for a minifier, if nothing else. :)
What I don't know is how Pegasus is related to DBZ.

Also what about adding some Yu Yu Hakusho references?

Side note, how do you like posts? I don't seem to  have the option to do it.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2059
The Like button should be next to the quote button, and Reply is under "More" right next to that.  At least on the default theme.

As for Pegasus, the name predates miniSphere.  I didn't come up with that one.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2060
Interestingly, Chakra seems to have something called "time travel debugging" that I guess lets you step backwards through your code to retrace the cause of a bug.  It's listed as experimental, but that's pretty neat.  That would be an awesome feature for SSj to have.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2061
I'm still getting an occasional segfault in miniSphere, so I compiled a debug build of ChakraCore and ran miniSphere with it.  I keep seeing an assertion here:
https://github.com/Microsoft/ChakraCore/blob/v1.7.1/lib/Common/Memory/Recycler.inl#L59

If I continue execution from that point, I continue to get assert failures in various random locations throughout the GC code.  So I'm apparently doing something bad and confusing the garbage collector, and every once in a while it causes a hard crash.

EDIT: It seems like I'm not supposed to be calling into the JS engine at all during a finalizer call.  This will require me to change how my finalizers work, since Duktape treated them just like any other JS function call.

I hope CC isn't calling finalizers on a different thread, because my objects are internally reference counted and that would lead to very ugly race conditions.
  • Last Edit: September 04, 2017, 11:53:30 am by Fat Cerberus
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Rhuan
  • [*][*][*][*]
Re: miniSphere 4.8.4
Reply #2062
I hope CC isn't calling finalizers on a different thread, because my objects are internally reference counted and that would lead to very ugly race conditions.
I think that there is a high chance that that is exactly what it's doing as one of CC's "features" is that it runs it's GC in a separate thread to avoid slowing down the execution thread, I'd imagine that the GC thread calls the finalisers.

If editing miniSphere to not have a problem with finalisers being off thread is a problem an alternative may be to edit the CC header CommonDefines.h prior to compiling CC there's a flag in there called ENABLE_CONCURRENT_GC, at a glance it looks like disabling this will result in the GC being run on the main thread, bad for performance but may fix the problem.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2063
Thinking about the scenarios a bit, it might not be a problem.  There are a few possibilities:

  • GC calls finalizer, Sphere unrefs internal pointer, sees refcount = 0 and frees it.  By definition this means JS code no longer has a reference to it so it can't be passed to something else after being freed
  • GC calls finalizer, refcount still > 0 after unref so left alone.  Even if the refcounts get out of sync for a split second, everything is still fine in this case.

In general, the way the engine is designed, objects exposed to JS don't change hands internally unless JS code actually does something to trigger it.  And a refcount update itself is atomic.  So the off-thread finalization should actually be fine.

The crash seems to be caused by me creating new JS values during a finalizer call, which is a no-no.  I should be able to fix it easily enough.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2064
Okay, I rewrote all the finalizers to take a native pointer directly instead of trying to read it from the JS object being finalized.  That seems to have fixed the random crashes, so I guess that was it.  Even better, finalizers now get called on shutdown again, so hopefully Valgrind will stop complaining about me leaking crazy amounts of memory.

One surefire way I found to trigger the crash in a hurry was to run a game that calls lots of Prim functions every frame.  That creates a ton of GC stress because it constantly creates temporary shapes which get drawn and then immediately go out of scope.  The kh2bar demo in particular tended to trigger it, as well as the Spectacles battle engine sooner or later because the battle screen includes a kh2bar.  I'll keep testing naturally, but the engine seems to be fully stable now. :sunglasses:

Progress report on SSj/SSj Blue:
  • Resume, pause, step commands work.
  • Source code download works.
  • Any uncaught error triggers a breakpoint, although it's a bit glitchy in that the same error will trigger multiple breakpoints depending on how many native calls it hits on the way to the bottom of the stack.  This is a limitation in the way JSAL works so I'm not sure it can be fixed easily.  In any case, it's an uncaught errro so the end result is the same regardless (game crash).
  • backtrace sort of works, all calls currently listed as "function".
  • eval, examine, and vars commands DON'T work.
  • Line-based breakpoints DON'T work.
  • SSj Blue is glitchy; among other things, after a breakpoint is hit the wrong line and/or file is highlighted, and it tends to throw a lot of exceptions
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2065
Hm, weird.  On Linux, asprintf() exists but requires you to define _GNU_SOURCE (i.e. it's nonstandard, even in POSIX).  On OS X (and presumably iOS) it's provided by default.  Windows doesn't have it at all.  So it should be enough just to exclude my custom implementation if __APPLE__ is defined.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2066
SSj is slowly coming back online:
Code: [Select]
D:\src\spectacles-i>ssj dist
SSj X.X.X Sphere JavaScript debugger (x64)
the powerful symbolic JS debugger for Sphere
(c) 2015-2017 Fat Cerberus

starting 'D:/src/spectacles-i/dist/'... OK.
connecting to 127.0.0.1:1208... OK.
establishing communication... OK.
querying target... OK.
    game: Spectacles: Bruce's Story
    author: Fat Cerberus

=> # 0: function() at @/scripts/main.js:6
6 RequireSystemScript('persist.js');

@/scripts/main.js:6 function()
(ssj) c
throw: Object doesn't support property or method 'maskPerson'
    at @/scripts/maps/Testville.js:141
=> # 0: function() at @/scripts/maps/Testville.js:141
141                                     new Scene()

@/scripts/maps/Testville.js:141 function()
(ssj) l
    136                                 }
    137                                 if (!IsCameraAttached()) {  // it seems Scott got eaten...
    138                                         var session = persist.getWorld().session;
    139                                         session.party.remove('scott');
    140                                         session.party.add('maggie', 100);
=>  141                                         new Scene()
    142                                                 .fork()
    143                                                         .maskPerson('maggie', CreateColor(0, 0, 0, 0), 8)
    144                                                         .setSprite('maggie', 'battlers/maggie_hippo.rss')
    145                                                         .maskPerson('maggie', CreateColor(255, 255, 255, 255), 8)

@/scripts/maps/Testville.js:141 function()
(ssj) bt
=> # 0: function() at @/scripts/maps/Testville.js:141
   # 1: function() at #/game_modules/thread.js:195
   # 2: function() at #/runtime/from.js:267
   # 3: function() at #/runtime/from.js:706
   # 4: function() at #/runtime/from.js:101
   # 5: function() at #/game_modules/thread.js:187
   # 6: function() at @/scripts/main.js:60

@/scripts/maps/Testville.js:141 function()
(ssj) _
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2067
By the way, that source code listing... that works even for SPK-packaged games... even if you don't have the original source available.  SSj downloads the code directly from miniSphere.  That's a big reason I wanted native ES6 support, actually.  Otherwise you just see the ugly transpiled code in the debugger. :P
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.8.4
Reply #2068
@Rhuan The TextDecoder and TextEncoder objects have made their glorious return!  Now you can test your map engine with a CC-powered Sphere build. :smiley_cat:
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Rhuan
  • [*][*][*][*]
Re: miniSphere 4.8.4
Reply #2069
So I downloaded the latest copy of the miniSphere ChakraCore branch.

1. I initially tried building it linked against the bleeding edge of chakracore -> segfault (malloc with invalid address) the moment it tried to run a script.

2. I built it linked against an older version of chakracore - not sure what version -> it starts BUT:
a) attempting to load another game from the startup game resulted in "one or more components failed to load miniSphere cannot continue in this state"
b) running my map engine test by opening the manifest with minisphere it ran BUT I got a segfault when I quit (EXC_BAD_ACCESS - it looks like an object being accessed after it was freed

I'll try testing against the 1.71 release of CC instead of using the bleeding edge and see if there's a difference
  • Last Edit: September 06, 2017, 07:30:49 pm by Rhuan