jazz-soft / JZZ

MIDI library for Node.js and web-browsers
http://jazz-soft.net/doc/JZZ/
MIT License
525 stars 27 forks source link

DOM nodes keeps increasing #76

Open vfxturjo opened 1 year ago

vfxturjo commented 1 year ago

hi. i am trying to understand why DOM nodes count is increasing constantly image

i found this div to be reacting automatically in the background... image

if i remove this event listener, i get this: the div gets filled with lots of texts... mainly this is midi device ports... image

i am thinking why did this happen?? i searched for possible reasons for this dom to be created and found this. (it might help demystify..?) image

if i let it run, the count goes crazy high like this... image 😭

i dont understand why this is happening and how to fix... please help

my code may be the problem, but i want to know why it happened and how to avoid this problem...

vfxturjo commented 1 year ago

hi. update: I found that commenting out this line solves the problem.

image

and by analysing, i found: image

when i click on refresh button which does JZZ().refresh() method, the <div id="jazz-midi-msg">...</div> updates. also, DOM node count increases by 3.

if i remove the event listener... image

then on each run of JZZ().refresh() method, one line is added: (i clicked 5 times) image

so, i think JZZ().refresh() method is keeping history of all times when refresh() method is called. maybe to compare the current value with previous one to see if there is any difference? (just my thought), but it uses memory and DOM. is this intentional? or is this a bug?

jazz-soft commented 1 year ago

This DIV is used to communicate with the Jazz-MIDI browser extension. The event listener reads it and then cleans it up. I don't understand what you are trying to accomplish by removing the event listener.

vfxturjo commented 1 year ago

I see... I removed the event listener just to try to understand what it does.

Mainly my problem is with DOM nodes count. I mean, even if i didn't remove the event listener, the count was increasing gradually.

Mainly if i use JZZ().refresh() method. (+3 DOM nodes per call) Or if i subscribe to onChange() method... (+3 or +6 DOM nodes per second)

I was trying to understand if this is normal or not... that constant increase of DOM nodes count