exokitxr / exokit

Native VR/AR/XR engine for JavaScript 🦖
MIT License
995 stars 117 forks source link

Memory leaks running overnight #662

Open avaer opened 5 years ago

avaer commented 5 years ago

Reports from @shaneharris that leaving The Expanse open for a long time causes a heap overflow:

  <--- Last few GCs --->

  [13256:000001CB67DE86B0] 36263432 ms: Mark-sweep 1313.6 (1455.0) -> 1313.5 (1424.0) MB, 1320.9 / 0.0 ms  (average mu = 0.268, current mu = 0.186) last resort GC in old space requested
  [13256:000001CB67DE86B0] 36265085 ms: Mark-sweep 1313.5 (1424.0) -> 1313.5 (1424.0) MB, 1653.3 / 0.0 ms  (average mu = 0.140, current mu = 0.000) last resort GC in old space requested

  <--- JS stacktrace --->

  ==== JS stack trace =========================================

      0: ExitFrame [pc: 000003A880D841C1]
  Security context: 0000011AD619E6C9 <JSObject>
      1: _(aka _) [000002416A7390B9] [https://cdn.jsdelivr.net/gh/aframevr/aframe@7767ba1b2f10b2129acbfdad1c25666b99db4966/dist/aframe-master.min.js:~98] [pc=000003A88156F407](this=000002C2B88022E1 <undefined>,t=00000
  39F20937D01 <_e map = 0000023B64013A29>,e=000002C2B88022E1 <undefined>,r=0000005C5F1396E1 <W map = 000003FBA4447221>,n=00000285D15C70E1 <q ma...

  FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
   1: 00007FF6586B82F5
   2: 00007FF658694156
   3: 00007FF658695890
   4: 00007FF658B8AD5E
   5: 00007FF658B8AC93
   6: 00007FF658A69CB4
   7: 00007FF658A67A6A
   8: 00007FF658971326
   9: 00007FF658E0919D
  10: 00007FF658E07F39
  11: 00007FF658D7960E
  12: 00007FF658D73607
  13: 00007FF658CBAD9A
  14: 00007FF658CBD4EC
  15: 00007FF658D0E6E5
  16: 00007FF658BCDB43
  17: 00007FF658AD6027
  18: 000003A880D841C1
avaer commented 5 years ago

Waiting on a heap snapshot for this one.

avaer commented 5 years ago

Heap snapshot from The Expanse: https://file.io/it121j

avaer commented 5 years ago

We reduced this to A-Frame's raycaster component leaking: https://github.com/aframevr/aframe/blob/master/src/components/raycaster.js

My first guess is this has to do with DOM and/or MutationObserver.

sidequestlegend commented 5 years ago

Repro : https://cumbersome-cirrus.glitch.me/