Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26239] Android: Window leak in Ti.UI.currentWindow

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-04-23T18:28:39.000+0000
Affected Version/sRelease 7.3.0, Release 7.2.0
Fix Version/sRelease 8.0.1
ComponentsAndroid
Labelsandroid, cache, engSchedule, leak, module, require
ReporterSergey Volkov
AssigneeGary Mathews
Created2018-07-26T09:02:38.000+0000
Updated2019-04-23T18:28:39.000+0000

Description

Steps to reproduce: 1. Create application, put attached files in Resources 2. Run ti build with --debug-host localhost:8990 3. Open chrome-devtools:// link in Chrome 4. Resume script execution, wait for app load 5. In memory tab, press "Take snapshot" 6. In app press "OPEN 2ND WINDOW" 7. In memory tab, press "Take snapshot" 8. In app press "OPEN 3RD WINDOW" 9. In memory tab, press "Take snapshot" 10. In app press back button 11. In memory tab, press "Take snapshot" 12. In app press back button 13. In memory tab, press "Take snapshot" Now you got five snapshots. 1. Select "Snapshot 2" 2. Change "Summary" to "Comparison", put "Window" in "Class filter" 3. Expand "Window", observe one new "Window" instance, remember @id 4. Select "Snapshot 5", put "Window" in "Class filter" 5. Expand "Window", observe three instance of "Window" 6. Select "Window" instance with @id from (3) 7. Observe "Retainers" below

Attachments

FileDateSize
0001-Android-fix-Ti.UI.currentWindow-leak.patch2018-07-26T09:47:01.000+00003585
app.js2018-07-26T08:57:07.000+0000276
win2.js2018-07-26T08:57:07.000+0000333
win3.js2018-07-26T08:57:07.000+0000339

Comments

  1. Sergey Volkov 2018-07-26

    In summary: first require (once for each module) cause enclosuring current "Window" in "Ti.UI.currentWindow" which persist in context of this module. Since modules are cached this means that this "Window" (and all its children) will not be collected by gc. Same goes for "Ti.UI.currentActivity".
  2. Hans Knöchel 2018-07-26

    The Ti.UI.currentWindow property has been removed since 6.0.0, but I assume you mean the general window scope? cc [~jquick]
  3. Sergey Volkov 2018-07-26

    >The Ti.UI.currentWindow property has been removed since 6.0.0 It is still there for android, look at the patch in attachments.
  4. Hans Knöchel 2018-07-26

    I see! But shouldn't it be removed there as well? I see that your PR might do exactly that (not an Android pro here) :-)
  5. Joshua Quick 2018-07-26

    This is something we're already actively looking into. Pleas see the below. https://github.com/appcelerator/titanium_mobile/pull/10195
  6. Sergey Volkov 2018-07-27

    It's good to know, but actually that PR does not cover this case. Leak is in titanium.js and not in java side.
  7. Sergey Volkov 2018-08-07

    bq. Status: RESOLVED The PR that Joshua mentioned above and both PRs labeled as "TIMOB-26239" are not related to this issue.
  8. Sergey Volkov 2018-08-13

    Hello everyone. Just trying to say that nothing has been done yet to address this issue. P.S. "User mention" feature seems not working (or disabled for me), hope Joshua Quick and Gary Mathews will receive notification anyway.
  9. Joshua Quick 2018-08-15

    We'll re-look into this later. For now, we're rolling with what we've got for 7.3.0 since it has full Android 8 support and targeting it is currently required by Google Play.
  10. Sergey Volkov 2019-03-05

    https://github.com/appcelerator/titanium_mobile/pull/10749
  11. Gary Mathews 2019-03-21

    8_0_X: https://github.com/appcelerator/titanium_mobile/pull/10792
  12. Keerthi Mahalingam 2019-03-28

    FR Passed. waiting for resolving jenkin test failure to merge.
  13. Christopher Williams 2019-04-03

    Merged to 8_0_X and master
  14. Keerthi Mahalingam 2019-04-23

    Verified the fix on SDK 8.1.0.v20190423074844 and 8.0.1.v20190418104938. works as expected.Closing
        Name                        = Mac OS X
          Version                     = 10.13.6
        Node.js
          Node.js Version             = 8.9.1
          npm Version                 = 5.5.1
        Titanium CLI
          CLI Version                 = 5.1.1
        Appc cli =7.0.11-70X.1
        Device = one plus 5t android 9
        Emulator =pixel android 8
        Titanium SDK

JSON Source