Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I load multiple ace editor sessions without multiple worker requests #2707

Closed
somanathreddy opened this issue Oct 17, 2015 · 1 comment

Comments

@somanathreddy
Copy link

I have the following code which basically loads three JavaScript ace editor sessions:

But the problem is for each and every session it creates new worker-javascript.js network request for the same mode. I am supposed to have editor for 10 to 30 JavaScript ace-editor sessions in the single page to write different functions in JavaScript at various places, so this is eating memory and getting my Chrome browser crashed as it is requesting the worker every time for the same mode.

Following is my sample html file: (With angular app)

<!DOCTYPE <!DOCTYPE html>
<html ng-app="editorApp">
<head>
  <title>Ace editor tst</title>
  <script type="text/javascript" src="bower_components/angular/angular.js"></script>
  <script type="text/javascript" src="bower_components/ace-builds/src/ace.js"></script>
  <script type="text/javascript" src="bower_components/angular-ui-ace/ui-ace.js"></script>
  <script type="text/javascript" src="bower_components/ace-builds/src/ext-language_tools.js"></script>
  <script type="text/javascript" src="index.js"></script>
  <style type="text/css">
    .e1 { height: 200px; margin-bottom: 5px;}
    .e2 { height: 200px; margin-bottom: 5px;}
    .e3 { height: 200px; margin-bottom: 5px;}
  </style>
</head>
<body ng-controller="appCtrl">
  <div class="e1" ui-ace="{
  workerPath: 'bower_components/ace-builds/src-min-noconflict/',
  useWrapMode : true,
  showGutter: true,
  theme:'twilight',
  firstLineNumber: 1,
  onLoad: aceLoaded,
  onChange: aceChanged,
  require: ['ace/ext/language_tools'],
  advanced: {
  enableSnippets: true,
  enableBasicAutocompletion: true,
  enableLiveAutocompletion: true
}
}"></div>
<div class="e2" ui-ace="{
workerPath: 'bower_components/ace-builds/src-min-noconflict/',
useWrapMode : true,
showGutter: true,
theme:'twilight',
firstLineNumber: 1,
onLoad: aceLoaded,
onChange: aceChanged,
require: ['ace/ext/language_tools'],
advanced: {
enableSnippets: true,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true
}
}"></div>
<div class="e3" ui-ace="{
workerPath: 'bower_components/ace-builds/src-min-noconflict/',
useWrapMode : true,
showGutter: true,
theme:'twilight',
firstLineNumber: 1,
onLoad: aceLoaded,
onChange: aceChanged,
require: ['ace/ext/language_tools'],
advanced: {
enableSnippets: true,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true
}
}"></div>
</body>
</html>

Following is my controller: (index.js)

var app = angular.module('editorApp', ['ui.ace']);
app.controller('appCtrl', function($scope){
    $scope.aceLoaded = function(_editor){
        var _session = _editor.getSession();
        _session.setMode('ace/mode/javascript');
        var _renderer = _editor.renderer;
        _editor.$blockScrolling = Infinity;
    }

/*    $scope.acesession = "";
    $scope.aceLoaded = function(_editor){
        var _session = "";
        if(!$scope.acesession) {
            _session = _editor.getSession();
            _session.setMode('ace/mode/javascript');
            $scope.acesession = _session;
        }
        else {
            _session = $scope.acesession;
        }

        var _renderer = _editor.renderer;
        _editor.$blockScrolling = Infinity;
    }*/
});

I have even tried by using the same session (commented code above) as discussed at #344 , but didn't work.

Any help would be appreciated.

Plnkr is here http://plnkr.co/edit/lJUAW9EXsiC7RVuga9ia

@github-actions
Copy link

github-actions bot commented May 9, 2022

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

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

No branches or pull requests

1 participant