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 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. # 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 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 window.BOX2D_ENABLED = true
@shared.lastSerializedWorldFrames = serialized.frames @shared.lastSerializedWorldFrames = serialized.frames
finishBeholdingWorld: (goalStates) -> (world) => finishBeholdingWorld: (goalStates) -> (world) =>
return if @aborting return if @aborting
@streamingWorld = world
finished = world.frames.length is world.totalFrames finished = world.frames.length is world.totalFrames
firstChangedFrame = world.findFirstChangedFrame @shared.world firstChangedFrame = world.findFirstChangedFrame @shared.world
eventType = if finished then 'god:new-world-created' else 'god:streaming-world-updated' 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.' @say 'Fired worker.'
@initialized = false @initialized = false
@work = null @work = null
@streamingWorld = null
@deserializationQueue = null
@hireWorker() if rehire @hireWorker() if rehire
hireWorker: -> 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. 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 transferableStorageBytesNeeded = 0
nFrames = endFrame - startFrame nFrames = endFrame - startFrame
streaming = nFrames < @totalFrames
for thang in @thangs for thang in @thangs
# Don't serialize empty trackedProperties for stateless Thangs which haven't changed (like obstacles). # 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). # 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 w.frames = [] unless streamingWorld
clearTimeout @deserializationTimeout if @deserializationTimeout clearTimeout @deserializationTimeout if @deserializationTimeout
@deserializationTimeout = _.delay @deserializeSomeFrames, 1, o, w, finishedWorldCallback, perf, startFrame, endFrame @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 # Spread deserialization out across multiple calls so the interface stays responsive
@deserializeSomeFrames: (o, w, finishedWorldCallback, perf, startFrame, endFrame) => @deserializeSomeFrames: (o, w, finishedWorldCallback, perf, startFrame, endFrame) =>