Fixed bug with world deserialization missing state batches.

This commit is contained in:
Nick Winter 2014-10-02 15:33:23 -07:00
parent 987061cec6
commit abf28c2c19
2 changed files with 4 additions and 3 deletions

View file

@ -119,13 +119,12 @@ module.exports = class Angel extends CocoClass
return if @aborting
# Toggle BOX2D_ENABLED during deserialization so that if we have box2d in the namespace, the Collides Components still don't try to create bodies for deserialized Thangs upon attachment.
window.BOX2D_ENABLED = false
World.deserialize serialized, @shared.worldClassMap, @shared.lastSerializedWorldFrames, @finishBeholdingWorld(goalStates), startFrame, endFrame, streamingWorld
@streamingWorld = World.deserialize serialized, @shared.worldClassMap, @shared.lastSerializedWorldFrames, @finishBeholdingWorld(goalStates), startFrame, endFrame, streamingWorld
window.BOX2D_ENABLED = true
@shared.lastSerializedWorldFrames = serialized.frames
finishBeholdingWorld: (goalStates) -> (world) =>
return if @aborting
@streamingWorld = world
finished = world.frames.length is world.totalFrames
firstChangedFrame = world.findFirstChangedFrame @shared.world
eventType = if finished then 'god:new-world-created' else 'god:streaming-world-updated'
@ -208,6 +207,8 @@ module.exports = class Angel extends CocoClass
@say 'Fired worker.'
@initialized = false
@work = null
@streamingWorld = null
@deserializationQueue = null
@hireWorker() if rehire
hireWorker: ->

View file

@ -364,7 +364,6 @@ module.exports = class World
o.trackedPropertiesPerThangValuesOffsets = [] # Needed to reconstruct ArrayBufferViews on other end, since Firefox has bugs transfering those: https://bugzilla.mozilla.org/show_bug.cgi?id=841904 and https://bugzilla.mozilla.org/show_bug.cgi?id=861925 # Actually, as of January 2014, it should be fixed. So we could try to undo the workaround.
transferableStorageBytesNeeded = 0
nFrames = endFrame - startFrame
streaming = nFrames < @totalFrames
for thang in @thangs
# Don't serialize empty trackedProperties for stateless Thangs which haven't changed (like obstacles).
# Check both, since sometimes people mark stateless Thangs but then change them, and those should still be tracked, and the inverse doesn't work on the other end (we'll just think it doesn't exist then).
@ -477,6 +476,7 @@ module.exports = class World
w.frames = [] unless streamingWorld
clearTimeout @deserializationTimeout if @deserializationTimeout
@deserializationTimeout = _.delay @deserializeSomeFrames, 1, o, w, finishedWorldCallback, perf, startFrame, endFrame
w # Return in-progress deserializing world
# Spread deserialization out across multiple calls so the interface stays responsive
@deserializeSomeFrames: (o, w, finishedWorldCallback, perf, startFrame, endFrame) =>