Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

WIP: Fix electron freezing #2478

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open

WIP: Fix electron freezing #2478

wants to merge 7 commits into from

Conversation

prertik
Copy link
Member

@prertik prertik commented Jan 29, 2020

Experimental PR more commits to follow and changes to be dropped.

ipcRenderer.sendToHost("browser-raise", [meta.obj, meta.ev, {result: final, meta: meta}]);
return exp;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

meta["no-inspect"] = true;
var final = safeStringify(exp);
}
ipcRenderer.sendToHost("browser-raise", [meta.obj, meta.ev, {result: final, meta: meta}]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'final' used out of scope.

var final = cljs.core.pr_str(exp);
} else {
meta["no-inspect"] = true;
var final = safeStringify(exp);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'final' is already defined.

var nodeName = args.name.replace(/\./, "-");
var code = args.code;
var styleElem = document.createElement("style");
styleElem.type = "text/css"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

@@ -0,0 +1,110 @@
(function(window) {

const ipcRenderer = require("electron");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

_send(m.obj, "connect");
break;
case "register":
eval("funcs['" + m.name + "'] = " + m.func);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval can be harmful.

if(state.level === 2) {
curEntry.tokens.push({start: stream.start, end: stream.pos, value: stream.current(), type: "atom"});
} else if(state.level === 3) {
var lastToken = curEntry.tokens[curEntry.tokens.length - 1];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'lastToken' is already defined.

stream.start = stream.pos;
} else if(ch.match(chars)) {
stream.start = stream.pos - 1;
var pos = stream.pos;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'pos' is already defined.

if(state.level === 2) {
curEntry.tokens.push({start: stream.start, end: stream.pos, value: stream.current(), type: "keyword"});
} else if(state.level === 3) {
var lastToken = curEntry.tokens[curEntry.tokens.length - 1];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'lastToken' is already defined.

} else {
var expected = "the end of the file";
if(state.stack[state.stack.length - 1]) {
var expected = opposites[state.stack[state.stack.length - 1].type];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'expected' is already defined.

@lgtm-com
Copy link

lgtm-com bot commented Jan 29, 2020

This pull request introduces 1104 alerts when merging 6b37d26 into 3760844 - view on LGTM.com

new alerts:

  • 762 for Unused variable, import, function or class
  • 295 for Unreachable statement
  • 21 for Comparison between inconvertible types
  • 12 for Useless conditional
  • 6 for Duplicate character in character class
  • 4 for Unneeded defensive code
  • 2 for Self assignment
  • 1 for Useless assignment to local variable
  • 1 for Useless regular-expression character escape

// a stack trace is added to var message above. With this, a stack trace is
// not added until this line (it causes the extra garbage to be added after
// the assertion message instead of in the middle of it).
var e = new goog.asserts.AssertionError('' + message, args || []);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'args' used out of scope.

var args = givenArgs;
} else if (defaultMessage) {
message += ': ' + defaultMessage;
args = defaultArgs;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'args' used out of scope.

minLen = arguments[i].length;
}
}
for (var i = 0; i < minLen; i++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'i' is already defined.

array.push(i);
}
} else {
for (var i = start; i > end; i += step) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'i' is already defined.

return valueCompareFn(obj1.value, obj2.value) || obj1.index - obj2.index;
}
goog.array.sort(compArr, stableCompareFn);
for (var i = 0; i < arr.length; i++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'i' is already defined.

crate.binding.notifier.prototype.cljs$core$IWatchable$_add_watch$arity$3 = (function (this$,key,f){
var self__ = this;
var this$__$1 = this;
return this$__$1.watches = cljs.core.assoc.call(null,self__.watches,key,f);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to return a conditional instead of an assignment?

} else {
var vec__12443 = cljs.core.first.call(null,seq__12436__$1);
var key = cljs.core.nth.call(null,vec__12443,(0),null);
var f = cljs.core.nth.call(null,vec__12443,(1),null);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'f' is already defined.

continue;
} else {
var vec__12443 = cljs.core.first.call(null,seq__12436__$1);
var key = cljs.core.nth.call(null,vec__12443,(0),null);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'key' is already defined.

this.watches = watches;
this.cljs$lang$protocol_mask$partition1$ = 2;
this.cljs$lang$protocol_mask$partition0$ = 0;
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

crate.binding.atom_binding = (function (atm,value_func){
this.atm = atm;
this.value_func = value_func;
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

goog.async.run.processWorkQueue = function() {
// NOTE: additional work queue items may be added while processing.
var item = null;
while (item = goog.async.run.workQueue_.remove()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected a conditional expression and instead saw an assignment.

* The function used to schedule work asynchronousely.
* @private {function()}
*/
goog.async.run.schedule_;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected an assignment or function call and instead saw an expression.

return function(cb) {
tail.next = {cb: cb};
tail = tail.next;
channel['port2'].postMessage(0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['port2'] is better written in dot notation.

// Use a fifo linked list to call callbacks in the right order.
var head = {};
var tail = head;
channel['port1'].onmessage = function() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['port1'] is better written in dot notation.

}, this);
win.addEventListener('message', onmessage, false);
this['port1'] = {};
this['port2'] = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['port2'] is better written in dot notation.

var tag_attrs = cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.filter.call(null,((function (vec__12734,_,tag__$1,id,class$,vec__12737,nsp,tag__$2,vec__12731,seq__12732,first__12733,seq__12732__$1,tag,content){
return (function (p1__12717_SHARP_){
return !((cljs.core.second.call(null,p1__12717_SHARP_) == null));
});})(vec__12734,_,tag__$1,id,class$,vec__12737,nsp,tag__$2,vec__12731,seq__12732,first__12733,seq__12732__$1,tag,content))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misleading line break before ','; readers may interpret this as an expression boundary.

var tag__$2 = cljs.core.nth.call(null,vec__12737,(1),null);
var tag_attrs = cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.filter.call(null,((function (vec__12734,_,tag__$1,id,class$,vec__12737,nsp,tag__$2,vec__12731,seq__12732,first__12733,seq__12732__$1,tag,content){
return (function (p1__12717_SHARP_){
return !((cljs.core.second.call(null,p1__12717_SHARP_) == null));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confusing use of '!'.

case 3:
return crate.compiler.dom_attr.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));

break;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable 'break' after 'return'.

case 2:
return crate.compiler.dom_attr.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable 'break' after 'return'.

case 3:
return crate.compiler.dom_style.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));

break;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable 'break' after 'return'.

*/
goog.json.serialize = goog.json.USE_NATIVE_JSON ?
/** @type {function(*, ?goog.json.Replacer=):string} */
(goog.global['JSON']['stringify']) :
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['JSON'] is better written in dot notation.
['stringify'] is better written in dot notation.

*
* @typedef {function(this:Object, string, *): *}
*/
goog.json.Reviver;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected an assignment or function call and instead saw an expression.

*
* @typedef {function(this:Object, string, *): *}
*/
goog.json.Replacer;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected an assignment or function call and instead saw an expression.

/** @type {function(string):Object} */ (goog.global['JSON']['parse']) :
function(s) {
return /** @type {Object} */ (
eval('(' + s + ')'));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval can be harmful.

* @return {Object} The object generated from the JSON string.
*/
goog.json.unsafeParse = goog.json.USE_NATIVE_JSON ?
/** @type {function(string):Object} */ (goog.global['JSON']['parse']) :
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['JSON'] is better written in dot notation.
['parse'] is better written in dot notation.

* The current key visited during iteration.
* @type {KEY}
*/
this.currentKey;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected an assignment or function call and instead saw an expression.

* The target key for determining the start of a group.
* @type {KEY}
*/
this.targetKey;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected an assignment or function call and instead saw an expression.

*/
goog.iter.dropWhile = function(iterable, f, opt_obj) {
var iterator = goog.iter.toIterator(iterable);
var newIter = new goog.iter.Iterator;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing '()' invoking a constructor.

*/
goog.iter.map = function(iterable, f, opt_obj) {
var iterator = goog.iter.toIterator(iterable);
var newIter = new goog.iter.Iterator;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing '()' invoking a constructor.

throw Error('Range step argument must not be zero');
}

var newIter = new goog.iter.Iterator;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing '()' invoking a constructor.

}

// Send the message via the NIX wrapper object.
this.nixChannel_['SendMessage'](service, payload);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['SendMessage'] is better written in dot notation.

this.nixChannel_ = channel;

// Ensure that the NIX channel given to use is valid.
var remoteAuthToken = this.nixChannel_['GetAuthToken']();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['GetAuthToken'] is better written in dot notation.

// wrapper to the container via the channel they gave us.
var theWindow = this.getWindow();
var getWrapper = theWindow[goog.net.xpc.NixTransport.NIX_GET_WRAPPER];
this.nixChannel_['CreateChannel'](getWrapper(this, this.authToken_));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['CreateChannel'] is better written in dot notation.

this.nixChannel_ = opener;

// Ensure that the NIX channel given to use is valid.
var remoteAuthToken = this.nixChannel_['GetAuthToken']();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['GetAuthToken'] is better written in dot notation.


try {
listenWindow.execScript(vbscript, 'vbscript');
listenWindow['nix_setup_complete'] = true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['nix_setup_complete'] is better written in dot notation.

}));
var ifr = div.childNodes[0];
div = null;
ifr['xpcOnload'] = goog.net.xpc.IframeRelayTransport.iframeLoadHandler_;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['xpcOnload'] is better written in dot notation.

}

goog.net.xpc.channels[channelName].xpcDeliver(
service, decodeURIComponent(payload));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'service' used out of scope.

} else {
// There was a fragment id in the header, so this is a message
// fragment, not a whole message.
var service = header.substr(0, pos);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'service' is already defined.

*/
goog.net.xpc.IframeRelayTransport.prototype.connect = function() {
if (!this.getWindow()['xpcRelay']) {
this.getWindow()['xpcRelay'] =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['xpcRelay'] is better written in dot notation.

* @override
*/
goog.net.xpc.IframeRelayTransport.prototype.connect = function() {
if (!this.getWindow()['xpcRelay']) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['xpcRelay'] is better written in dot notation.

}
} else {
var p = cljs.core.first.call(null,s__19606__$2);
return cljs.core.cons.call(null,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"span.param","span.param",-2079989519),new cljs.core.Keyword(null,"label","label",1718410804).cljs$core$IFn$_invoke$arity$1(p),(cljs.core.truth_(new cljs.core.Keyword(null,"example","example",-1755779144).cljs$core$IFn$_invoke$arity$1(p))?cljs.core._conj.call(null,(function (){var x__7627__auto__ = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"pre.example","pre.example",-1014445954),new cljs.core.Keyword(null,"example","example",-1755779144).cljs$core$IFn$_invoke$arity$1(p)], null);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions declared within loops referencing an outer scoped variable may lead to confusing semantics. (cljs, p)

while(true){
if((i__19607 < size__7572__auto__)){
var p = cljs.core._nth.call(null,c__7571__auto__,i__19607);
cljs.core.chunk_append.call(null,b__19608,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"span.param","span.param",-2079989519),new cljs.core.Keyword(null,"label","label",1718410804).cljs$core$IFn$_invoke$arity$1(p),(cljs.core.truth_(new cljs.core.Keyword(null,"example","example",-1755779144).cljs$core$IFn$_invoke$arity$1(p))?cljs.core._conj.call(null,(function (){var x__7627__auto__ = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"pre.example","pre.example",-1014445954),new cljs.core.Keyword(null,"example","example",-1755779144).cljs$core$IFn$_invoke$arity$1(p)], null);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions declared within loops referencing an outer scoped variable may lead to confusing semantics. (cljs, p)

var c__7571__auto__ = cljs.core.chunk_first.call(null,s__19606__$2);
var size__7572__auto__ = cljs.core.count.call(null,c__7571__auto__);
var b__19608 = cljs.core.chunk_buffer.call(null,size__7572__auto__);
if((function (){var i__19607 = (0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions declared within loops referencing an outer scoped variable may lead to confusing semantics. (size__7572__auto__, cljs, c__7571__auto__, b__19608)

*
*/
lt.objs.langs.behaviors.__BEH__behavior_hint_pattern = (function lt$objs$langs$behaviors$__BEH__behavior_hint_pattern(this$){
return lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"hint-pattern","hint-pattern",-1622710880),/[\w\-\>\:\*\$\?\<\!\+\.\"\\/]/], null));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected escaped character '<' in regular expression.

lt.objs.langs.behaviors.__BEH__show_info_on_move = (function lt$objs$langs$behaviors$__BEH__show_info_on_move(this$){
var idx = lt.objs.langs.behaviors.__GT_index.call(null,this$);
var map__19589 = lt.objs.langs.behaviors.idx__GT_entry_info.call(null,idx,new cljs.core.Keyword(null,"entries","entries",-86943161).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$)));
var map__19589__$1 = ((((!((map__19589 == null)))?((((map__19589.cljs$lang$protocol_mask$partition0$ & (64))) || (map__19589.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__19589):map__19589);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confusing use of '!'.

return (function (){
var me = this;
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"search!","search!",-612546952),lt.util.dom.val.call(null,me));
});})(e__7942__auto__))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misleading line break before ','; readers may interpret this as an expression boundary.

return cljs.core.vec.call(null,cljs.core.map.call(null,((function (segs,segs__$1){
return (function (p1__13561_SHARP_){
return [cljs.core.str(p1__13561_SHARP_),cljs.core.str(lt.objs.files.separator)].join('');
});})(segs,segs__$1))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misleading line break before ','; readers may interpret this as an expression boundary.

var cur = start;
var prev = "";
while(true){
if(cljs.core.truth_((function (){var or__6793__auto__ = cljs.core.empty_QMARK_.call(null,cur);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions declared within loops referencing an outer scoped variable may lead to confusing semantics. (cljs, cur, roots, prev)

case 1:
return lt.objs.files.lt_user_dir.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable 'break' after 'return'.

case 0:
return lt.objs.files.lt_user_dir.cljs$core$IFn$_invoke$arity$0();

break;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable 'break' after 'return'.

@lgtm-com
Copy link

lgtm-com bot commented Feb 10, 2020

This pull request introduces 1170 alerts when merging 17c9c5f into 3760844 - view on LGTM.com

new alerts:

  • 794 for Unused variable, import, function or class
  • 320 for Unreachable statement
  • 23 for Comparison between inconvertible types
  • 13 for Useless conditional
  • 6 for Useless assignment to local variable
  • 6 for Duplicate character in character class
  • 4 for Unneeded defensive code
  • 2 for Self assignment
  • 1 for Identical operands
  • 1 for Useless regular-expression character escape

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

Successfully merging this pull request may close these issues.

None yet

1 participant