activate-power-mode icon indicating copy to clipboard operation
activate-power-mode copied to clipboard

Uncaught TypeError: Cannot read property 'pixelPositionForScreenPosition' of null

Open thypon opened this issue 8 years ago • 7 comments

Whenever I hit Commit or Push with Git Plus plugin the following exception is raised.

Atom: 1.17.2 x64 Electron: 1.3.15 OS: "Void Linux" Thrown From: activate-power-mode package 2.0.0

Stack Trace

Uncaught TypeError: Cannot read property 'pixelPositionForScreenPosition' of null

At /usr/share/atom/resources/app/src/text-editor-element.js:304

TypeError: Cannot read property 'pixelPositionForScreenPosition' of null
    at atom-text-editor.TextEditorElement.pixelPositionForScreenPosition (/usr/share/atom/resources/app/src/text-editor-element.js:304:28)
    at Object.calculatePositions (/packages/activate-power-mode/lib/canvas-renderer.coffee:96:34)
    at Object.spawn (/packages/activate-power-mode/lib/canvas-renderer.coffee:77:17)
    at invokeFunc (/packages/activate-power-mode/node_modules/lodash.throttle/index.js:160:19)
    at leadingEdge (/packages/activate-power-mode/node_modules/lodash.throttle/index.js:170:22)
    at /packages/activate-power-mode/node_modules/lodash.throttle/index.js:235:16)
    at Object.onInput (/packages/activate-power-mode/lib/plugin/power-canvas.coffee:21:12)
    at /packages/activate-power-mode/lib/plugin-manager.coffee:103:16
    at Object.onEnabled (/packages/activate-power-mode/lib/plugin-registry.coffee:64:19)
    at Object.runOnInput (/packages/activate-power-mode/lib/plugin-manager.coffee:100:21)
    at /packages/activate-power-mode/lib/power-editor.coffee:54:22

Commands

     -0:57.4.0 editor:newline (input.hidden-input)
     -0:57.2.0 intentions:highlight (input.hidden-input)
     -0:57.1.0 core:save (input.hidden-input)
     -0:30.5.0 git-plus-context:add (span.name.icon.icon-file-text)
     -0:27.5.0 core:save (div.tool-panel.tree-view)
     -0:25.7.0 command-palette:toggle (div.tool-panel.tree-view)
     -0:23.4.0 core:confirm (input.hidden-input)
     -0:23.4.0 git-plus:commit (div.tool-panel.tree-view)
     -0:14.1.0 refactor:done (input.hidden-input)
     -0:14.1.0 editor:newline (input.hidden-input)
     -0:13.9.0 intentions:highlight (input.hidden-input)
     -0:13.8.0 core:save (input.hidden-input)
     -0:11.6.0 command-palette:toggle (div.tool-panel.tree-view)
  3x -0:10.9.0 core:backspace (input.hidden-input)
     -0:09.1.0 core:confirm (input.hidden-input)
     -0:09.1.0 git-plus:push (div.tool-panel.tree-view)

Non-Core Packages

activate-power-mode 2.0.0 
atom-pair 2.0.10 
autocomplete-clang 0.11.3 
autocomplete-java 1.2.7 
build 0.68.0 
build-gradle 0.6.0 
build-rake 0.1.1 
busy 0.7.0 
busy-signal 1.4.1 
file-watcher 1.1.0 
git-plus 7.9.2 
intentions 1.1.2 
language-arm 1.2.2 
language-gradle 0.0.3 
language-groovy 0.7.0 
language-latex 1.0.0 
language-markdown 0.22.0 
language-patch 1.2.0 
linter 2.1.4 
linter-rubocop 2.1.1 
linter-shellcheck 1.4.4 
linter-ui-default 1.6.0 
pdf-view 0.58.0 
refactor 0.11.4 
todo-show 1.11.0 
video-player 2.3.0 
wordcount 2.10.4 

thypon avatar May 29 '17 15:05 thypon

This happens constantly to me while typing, pausing, and typing again.

Edit2: I edited activate-power-mode/lib/candas-renderer.coffee around line 96, adding the not and null checks below, and the problem persists but seemingly less often. That could totally be the placebo effect, but I'll keep it here in case it helps someone else

calculatePositions: (screenPosition) ->
      if not @screenPosition
            return
      if @screenPosition == null
            return
      {left, top} = @editorElement.pixelPositionForScreenPosition screenPosition

Does anyone have an idea of what's causing these random null screenPositions?

asyncjake avatar Aug 04 '17 18:08 asyncjake

@lexcast you should check this.

Jerajo avatar Aug 05 '17 10:08 Jerajo

Is there a way to reproduce this? I'm using git plus to trying to reproduce with not luck.

lexcast avatar Aug 06 '17 17:08 lexcast

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.19.0 x64 Electron: 1.6.9 OS: Mac OS X 10.11.6 Thrown From: activate-power-mode package 2.0.0

Stack Trace

Uncaught TypeError: Cannot read property 'pixelPositionForScreenPosition' of null

At /Users/pratap/.atom/packages/activate-power-mode/lib/canvas-renderer.coffee:96

TypeError: Cannot read property 'pixelPositionForScreenPosition' of null
    at Object.calculatePositions (/packages/activate-power-mode/lib/canvas-renderer.coffee:96:33)
    at Object.spawn (/packages/activate-power-mode/lib/canvas-renderer.coffee:77:17)
    at invokeFunc (/packages/activate-power-mode/node_modules/lodash.throttle/index.js:160:19)
    at leadingEdge (/packages/activate-power-mode/node_modules/lodash.throttle/index.js:170:22)
    at /packages/activate-power-mode/node_modules/lodash.throttle/index.js:235:16)
    at Object.onInput (/packages/activate-power-mode/lib/plugin/power-canvas.coffee:21:12)
    at /packages/activate-power-mode/lib/plugin-manager.coffee:103:16
    at Object.onEnabled (/packages/activate-power-mode/lib/plugin-registry.coffee:64:19)
    at Object.runOnInput (/packages/activate-power-mode/lib/plugin-manager.coffee:100:21)
    at /packages/activate-power-mode/lib/power-editor.coffee:54:22

Commands

     -5:21.2.0 editor:consolidate-selections (input.hidden-input)
     -5:21.2.0 core:cancel (input.hidden-input)
  3x -5:20.6.0 core:save (input.hidden-input)
  3x -4:03.2.0 core:backspace (input.hidden-input)
  4x -4:01.7.0 core:save (input.hidden-input)
     -3:53 grammar-selector:show (atom-text-editor.editor.is-focused)
  2x -3:50.6.0 core:save (input.hidden-input)
     -3:49.5.0 editor:newline (input.hidden-input)
     -3:48.6.0 core:undo (input.hidden-input)
  5x -3:48.3.0 core:save (input.hidden-input)
  3x -2:21.5.0 core:backspace (input.hidden-input)
  3x -2:20.4.0 core:save (input.hidden-input)
  3x -0:44.7.0 core:backspace (input.hidden-input)
     -0:43.1.0 core:save (input.hidden-input)
  3x -0:37.1.0 core:backspace (input.hidden-input)
  2x -0:36 core:save (input.hidden-input)

Non-Core Packages

activate-power-mode 2.0.0 
atom-beautify 0.30.4 
atom-material-syntax 1.0.2 
atom-material-ui 1.3.9 
auto-indent 0.5.0 
autocomplete-python 1.9.1 
gtk-dark-theme 0.1.4 
seti-ui 1.4.0 
Sids-Syntax-Theme 1.0.0 

PratapDafedar avatar Aug 14 '17 06:08 PratapDafedar

@PratapDafedar Try to update to the latest release which is activate-power-mode: 2.2.0.

Also read these comment for more info.

Jerajo avatar Aug 14 '17 13:08 Jerajo

I put in some tracing logging calls and I get this error when input tries to .spawn because of input, but the canvas has already been destroyed.

canvas-render destroy called
    at Object.destroy (activate-power-mode/lib/canvas-renderer.coffee:44:36)
    at Object.disable (activate-power-mode/lib/plugin/power-canvas.coffee:15:13)
    at activate-power-mode/lib/plugin-manager.coffee:82:32
    at Object.onEnabled (activate-power-mode/lib/plugin-registry.coffee:92:19)
    at Object.disable (activate-power-mode/lib/plugin-manager.coffee:81:21)
    at Object.disable (activate-power-mode/lib/power-editor.coffee:17:20)
    at automate-power-mode/lib/automate-power-mode.js:46:28
canvas-renderer spawn called when editor is null
    at Object.spawn (activate-power-mode/lib/canvas-renderer.coffee:93:39)
    at invokeFunc (C:\Users\Luke\.atom\packages\activate-power-mode\node_modules\lodash.throttle\index.js:160:19)
    at leadingEdge (C:\Users\Luke\.atom\packages\activate-power-mode\node_modules\lodash.throttle\index.js:170:22)
    at Cursor.debounced [as spawn] (C:\Users\Luke\.atom\packages\activate-power-mode\node_modules\lodash.throttle\index.js:235:16)
    at Object.onInput (activate-power-mode/lib/plugin/power-canvas.coffee:27:12)
    at activate-power-mode/lib/plugin-manager.coffee:107:16
    at Object.onEnabled (activate-power-mode/lib/plugin-registry.coffee:92:19)
    at Object.runOnInput (activate-power-mode/lib/plugin-manager.coffee:104:21)
    at activate-power-mode/lib/power-editor.coffee:55:24
canvas-renderer.coffee:113 Uncaught TypeError: Cannot read property 'pixelPositionForScreenPosition' of null

I'm not certain why it would get disabled -- I suspect autocomplete, ide-typescript, or the linter package could trigger a disable. Or it could just be a race condition between the interval for disabling because the change threshold isn't exceeded, but input handler is still in place. Regardless, I created a pull which will just silently avoid triggering the error: https://github.com/JoelBesada/activate-power-mode/pull/327

lselden avatar Jan 05 '18 17:01 lselden

If you use automate-power-mode, which turns powermode on and off on the fly... this problem still occurs reliably... as it gets disabled and enabled often

FossPrime avatar Jun 27 '18 14:06 FossPrime