question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createEvent broken by mutating strings

See original GitHub issue

adding an event with createEvent

{
Duration: 4880,
Effect: "",
Layer: 0,
MarginL: 0,
MarginR: 0,
MarginV: 0,
Name: "",
ReadOrder: 0,
Start: 7870,
Style: 1,
Text: "Text."
}

for some reason creates an event that looks like:

{
Duration: 4880,
Effect: "Text.",
Layer: 0,
MarginL: 0,
MarginR: 0,
MarginV: 0,
Name: "Text.",
ReadOrder: 0,
Start: 7870,
Style: 1,
Text: "Text."
}

breaking the entire renderer, adding more subtitles with the createEvent function overwrites the text, effect and name values of the previous events

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
TFSThiagoBR98commented, Aug 8, 2021

WebIDL uses this 2 generated functions:

void EMSCRIPTEN_KEEPALIVE emscripten_bind_ASS_Event_set_Text_1(ASS_Event* self, char* arg0) {
  self->Text = arg0;
}

and its JS counterpart:

ASS_Event.prototype['set_Text'] = ASS_Event.prototype.set_Text = /** @suppress {undefinedVars, duplicate} */function(arg0) {
  var self = this.ptr;
  ensureCache.prepare();
  if (arg0 && typeof arg0 === 'object') arg0 = arg0.ptr;
  else arg0 = ensureString(arg0);
  _emscripten_bind_ASS_Event_set_Text_1(self, arg0);
};

Also the ensureString function:

function ensureString(value) {
  if (typeof value === 'string') {
    var intArray = intArrayFromString(value);
    var offset = ensureCache.alloc(intArray, HEAP8);
    ensureCache.copy(intArray, HEAP8, offset);
    return offset;
  }
  return value;
}

This uses the intArrayFromString function but Emscripten also have the stringToUTF8, see here

0reactions
ThaUnknowncommented, Oct 15, 2021

WebIDL uses this 2 generated functions:

void EMSCRIPTEN_KEEPALIVE emscripten_bind_ASS_Event_set_Text_1(ASS_Event* self, char* arg0) {
  self->Text = arg0;
}

and its JS counterpart:

ASS_Event.prototype['set_Text'] = ASS_Event.prototype.set_Text = /** @suppress {undefinedVars, duplicate} */function(arg0) {
  var self = this.ptr;
  ensureCache.prepare();
  if (arg0 && typeof arg0 === 'object') arg0 = arg0.ptr;
  else arg0 = ensureString(arg0);
  _emscripten_bind_ASS_Event_set_Text_1(self, arg0);
};

Also the ensureString function:

function ensureString(value) {
  if (typeof value === 'string') {
    var intArray = intArrayFromString(value);
    var offset = ensureCache.alloc(intArray, HEAP8);
    ensureCache.copy(intArray, HEAP8, offset);
    return offset;
  }
  return value;
}

This uses the intArrayFromString function but Emscripten also have the stringToUTF8, see here

so any chance this will get fixed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make mutation of a string? JavaScript - Stack Overflow
You are trying to change a primitive String , which is immutable in Javascript. For exmaple, something like below: var myObject = new...
Read more >
UI Events - W3C
The first goal is the design of an event system which allows registration of event listeners and describes event flow through a tree...
Read more >
EventTarget.addEventListener() - Web APIs | MDN
A case-sensitive string representing the event type to listen for. ... keyCode) { case 5: // some code here… break; case 6: //...
Read more >
20 Working with Event Rules
In JD Edwards EnterpriseOne, you create logic using event rules. Event rules are logic statements that are processed when an event, such as...
Read more >
Excel VBA Events - An Easy (and Complete) Guide
Excel VBA Events allow you to run a macro when a specific event occurs. An event could be an action such as opening...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found