Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Arrays within JavaScript files cause the UI to hang #493

Closed

Description

@helpfulBro

Prerequisites

Description

[Description of the issue]

Steps to Reproduce

  1. Create a test.js file and save it.
  2. Copy and paste a large array into the file e.g.
var occupationArray = [['Accountant','Accountant'],['Actor/Performer','Actor/Performer'],['Admin/Data Entry/Secretary','Admin/Data Entry/Secretary'],['Air Traffic Controller','Air Traffic Controller'],['Ambulance Officer/Manager','Ambulance Officer/Manager'],['Architect','Architect'],['Artist/Designer/Illustrator','Artist/Designer/Illustrator'],['Assembler','Assembler'],['Baker/Pastry Cook','Baker/Pastry Cook'],['Barrister/Solicitor','Barrister/Solicitor'],['Building/Construction Manager','Building/Construction Manager'],['Bursar','Bursar'],['Butcher/Smallgoods','Butcher/Smallgoods'],['Caretaker/Janitor','Caretaker/Janitor'],['Cashier','Cashier'],['Catering/Restaurant Manager','Catering/Restaurant Manager'],['Childcare/Youth Worker','Childcare/Youth Worker'],['Clerical Worker','Clerical Worker'],['Consultant','Consultant'],['Coroner/Judge/Magistrate','Coroner/Judge/Magistrate'],['Customer Service Consultant','Customer Service Consultant'],['Customs Agent','Customs Agent'],['Defence Forces','Defence Forces'],['Dishwasher/Kitchenhand','Dishwasher/Kitchenhand'],['Doctor/Specialist/Surgeon','Doctor/Specialist/Surgeon'],['Driver/Operator','Driver/Operator'],['Electrical/Electronic Engineer','Electrical/Electronic Engineer'],['Engineer','Engineer'],['Executive','Executive'],['Farmer','Farmer'],['Fire Brigade/Police','Fire Brigade/Police'],['Gardener/Landscaper','Gardener/Landscaper'],['Greenkeeper/Groundsperson','Greenkeeper/Groundsperson'],['HR/Recruitment','HR/Recruitment'],['Historian','Historian'],['Home Duties','Home Duties'],['Hospitality','Hospitality'],['Hotel Manager/Supervisor','Hotel Manager/Supervisor'],['IT Professional','IT Professional'],['Importer/Exporter','Importer/Exporter'],['Instructor','Instructor'],['Journalist/Proofreader','Journalist/Proofreader'],['Lab Technician','Lab Technician'],['Labourer/Factory/Process Worker','Labourer/Factory/Process Worker'],['Landscape Artist','Landscape Artist'],['Legal Officer','Legal Officer'],['Librarian','Librarian'],['Logistics','Logistics'],['Maintenance Engineer','Maintenance Engineer'],['Manager/Supervisor','Manager/Supervisor'],['Mechanic','Mechanic'],['Medical Lab Technician','Medical Lab Technician'],['Musician','Musician'],['Nurse/Midwife','Nurse/Midwife'],['Nursery and Garden Labourer','Nursery and Garden Labourer'],['Pharmacist','Pharmacist'],['Politician','Politician'],['Production','Production'],['Professional Sportsperson','Professional Sportsperson'],['Public Relations','Public Relations'],['Public Servant','Public Servant'],['Real Estate/Property','Real Estate/Property'],['Researcher','Researcher'],['Retail/Small Business Manager','Retail/Small Business Manager'],['Retired','Retired'],['Safety Inspector','Safety Inspector'],['Sales Rep','Sales Rep'],['Sales/Marketing/Advertising','Sales/Marketing/Advertising'],['Scientist/Mathematician','Scientist/Mathematician'],['Security Services/Officer','Security Services/Officer'],['Self-Employed','Self-Employed'],['Social Worker','Social Worker'],['Sole Trader','Sole Trader'],['Sound Technician','Sound Technician'],['Student','Student'],['Teacher','Teacher'],['Translator','Translator'],['Travel Agent/Consultant','Travel Agent/Consultant'],['Unemployed','Unemployed'],['University Lecturer/Teacher','University Lecturer/Teacher'],['Veterinarian','Veterinarian'],['Volunteer Work','Volunteer Work'],['Wholesale Manager','Wholesale Manager'],['Writer/Editor','Writer/Editor']];
  1. Or paste the array then try to save as .js

Expected behavior: The paste/save should only take a second or two to complete.

Actual behavior: The interface hangs, a message appears asking if you would like to wait. If you click wait enough times the paste/save will complete. Each time you touch the array this introduces an additional delay. The larger the array, the larger the delay.

Reproduces how often: 100%

Versions

Atom : 1.14.3
Electron: 1.3.13
Chrome : 52.0.2743.82
Node : 6.5.0
Windows 7x64 SP1

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Activity

  1. winstliu commented on Feb 21, 2017

    @winstliu
    Contributor

    If I remember correctly arrays are the only "bracket" structure in language-javascript that doesn't use nesting. So it seems counterintuitive that this one out of all three would be the one to have performance issues.

  2. helpfulBro commented on Feb 21, 2017

    @helpfulBro
    Author

    Other larger arrays types e.g. Array = (string1, string2, string3); do not have the same issue. It seems specific the square brackets. Well for me anyway.

  3. cayetanobv commented on Feb 22, 2017

    @cayetanobv

    And highlighting does not work properly. You can see screenshot:
    image

    Array example:

    var arr = [[0,random(10,12,2)],[1,random(8,10,2)],[2,random(4,6,2)],[4,random(4,6,2)],[5,random(10,12,2)],[6,random(12,18,2)],[7,random(30,40,2)],[8,random(40,50,2)],[9,random(40,55,2)],[10,random(60,70,2)],[11,random(50,60,2)],[12,random(30,40,2)],[13,random(40,50,2)],[14,random(40,50,2)],[15,random(50,60,2)],[16,random(30,40,2)],[17,random(30,40,2)],[18,random(50,60,2)],[19,random(50,60,2)],[20,random(40,50,2)],[21,random(30,40,2)],[22,random(20,30,2)],[23,random(15,20,2)],[24,random(10,12,2)]];
  4. winstliu commented on Feb 22, 2017

    @winstliu
    Contributor

    That is intentional, or else you would have a seriously bad time editing files with long lines. As in, Atom would probably crash. It is a built-in limitation to Atom's tokenizing engine.

  5. winstliu commented on Feb 26, 2017

    @winstliu
    Contributor

    I've confirmed this as a regression after bisecting between v0.122.0 and master. @Alhadis the offending commit is 7eec645, which you committed.

    EDIT: Specifically, it's the changes you made in the first half of the commit for getters and setters. It looks like the optional get/set part at the very beginning isn't that performant, because as soon as I make it required the performance is back to normal.

  6. Alhadis commented on Feb 26, 2017

    @Alhadis
    Contributor

    Sounds like a backtracking issue. Try this:

    -(\\b(get|set)\\s+)?       # Property getter/setter: get foo(){}
    +(\\b(get|set)\\s+)?+      # Property getter/setter: get foo(){}

    EDIT: Okay, nope, that alone isn't fixing it. I'll have a closer look.

  7. helpfulBro commented on Feb 27, 2017

    @helpfulBro
    Author

    Is there anything I can do within atom as a work around until this is included in a newer version?

  8. Alhadis commented on Feb 27, 2017

    @Alhadis
    Contributor

    @halcy0n9001 Once #494 is merged, you can link the latest changes to the package by linking it locally:

    cd ~/.atom/packages
    git clone https://github.com/atom/language-javascript.git

    Make sure to delete it after installing the next version of Atom which includes the fix.

  9. helpfulBro commented on Feb 27, 2017

    @helpfulBro
    Author

    @Alhadis
    Thank you

  10. added a commit that references this issue on Feb 27, 2017
    7844a3c
  11. winstliu commented on Feb 27, 2017

    @winstliu
    Contributor

    I'll be looking into getting this included in the next hotfix release.

  12. helpfulBro commented on Feb 27, 2017

    @helpfulBro
    Author

    Thanks @50Wliu & @Alhadis for the quick turn-around 👍

  13. winstliu commented on Mar 3, 2017

    @winstliu
    Contributor

    (Forgot to mention this here, but the fix went out in 1.15.0-beta4.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions