Uploaded image for project: 'Social Justice Repair Kit'
  1. Social Justice Repair Kit
  2. SJRK-369

Solve potential reorderer race condition on block addition

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Storytelling Tool UI
    • Labels:
      None

      Description

      The introduction of the reorderer component in the storyEditor grade brought along with it the potential for a race condition whenever new blocks are added.

      Ideally, we would like the reorderer to call its "refresh" invoker any time a new block is added, but if this is called while many blocks are being added simultaneously, errors will occur and break the page.

      The temporary solution is to delay calling "refresh" until any block has focus, but this results in many superfluous calls to refresh along with subsequent activation of various model relays and listeners related to autosave. These aren't harmful per se (yet), but they do waste cycles and the solution is inelegant and somewhat obscure.

      A better solution (proposed by Justin Obara) would be to implement a sort of event queue which, when a block is added:

      1. enqueues (pushes) an object containing the args of the viewComponentContainerRequested event and whatever else is needed for queue management (maybe nothing),
      2. fires the event, passing the args,
      3. dequeues (shifts) the object when the block fires its onTemplateRendered event, and finally
      4. calls refresh once the queue is empty (when length === 0)

      This solution may also require disabling adding new blocks while the refresh is underway (perhaps with a model value and associated listeners), otherwise the race condition is still present.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              gmoss Gregor Moss
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: