GithubHelp home page GithubHelp logo

Comments (29)

Molunerfinn avatar Molunerfinn commented on August 14, 2024

image
You can find the log file in the same folder of the config file. The log file is picgo.log

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

I can't reproduce in my Mac.

image

I have to look at your log file for more details

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

The picgo.log file remains unchanged, but I managed to capture the crash event at Event Viewer when executing "picgo upload".

image

提供程序“Registry”为 Started。

详细信息:
ProviderName=Registry
NewProviderState=Started

SequenceNumber=1

HostName=ConsoleHost
HostVersion=5.1.18362.628
HostId=7b77d0c9-eca8-4e0e-86dc-1419805a2b21
HostApplication=powershell -noprofile -noninteractive -nologo -sta -executionpolicy unrestricted -windowstyle hidden -file C:\Users\79917\node_modules\picgo\dist\src\utils\clipboard\windows10.ps1 C:\Users\79917\.picgo\20200309145807.png
EngineVersion=
RunspaceId=
PipelineId=
CommandName=
CommandType=
ScriptName=
CommandPath=
CommandLine=

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

image

提供程序“Alias”为 Started。

详细信息:
ProviderName=Alias
NewProviderState=Started

SequenceNumber=3

HostName=ConsoleHost
HostVersion=5.1.18362.628
HostId=7b77d0c9-eca8-4e0e-86dc-1419805a2b21
HostApplication=powershell -noprofile -noninteractive -nologo -sta -executionpolicy unrestricted -windowstyle hidden -file C:\Users\79917\node_modules\picgo\dist\src\utils\clipboard\windows10.ps1 C:\Users\79917\.picgo\20200309145807.png
EngineVersion=
RunspaceId=
PipelineId=
CommandName=
CommandType=
ScriptName=
CommandPath=
CommandLine=

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

image

提供程序“Environment”为 Started。

详细信息:
ProviderName=Environment
NewProviderState=Started

SequenceNumber=5

HostName=ConsoleHost
HostVersion=5.1.18362.628
HostId=7b77d0c9-eca8-4e0e-86dc-1419805a2b21
HostApplication=powershell -noprofile -noninteractive -nologo -sta -executionpolicy unrestricted -windowstyle hidden -file C:\Users\79917\node_modules\picgo\dist\src\utils\clipboard\windows10.ps1 C:\Users\79917\.picgo\20200309145807.png
EngineVersion=
RunspaceId=
PipelineId=
CommandName=
CommandType=
ScriptName=
CommandPath=
CommandLine=

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

image

image

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

image
image

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

image
image

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

image

image

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

image
image

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

image

image

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

Hope this help.

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

Not help. Maybe you can clone the repo, install and run npm run dev into the dev mode, then add some console.log into the Lifecycle.ts to see what happened.
Then use node ./bin/picgo upload to upload and see the log

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

Add these log commands.

      // lifecycle main
      console.log("To run 'beforeTransform'");
      await this.beforeTransform(this.ctx);
      console.log("'beforeTransform' ends");
      console.log("To run 'doTransform'");
      await this.doTransform(this.ctx);
      console.log("'doTransform' ends");
      console.log("To run 'beforeUpload'");
      await this.beforeUpload(this.ctx);
      console.log("'beforeUpload' ends");
      console.log("To run 'doUpload'");
      await this.doUpload(this.ctx);
      console.log("'doUpload' ends");
      console.log("To run 'afterUpload'");
      await this.afterUpload(this.ctx);
      console.log("'afterUpload' ends");
      return this.ctx;

And the result is
image

Any problem with your windows.ps1 or windows10.ps1 file?

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

Never change the files above in the recent releases. That's wired. Maybe you can check the .picgo folder to see if the windows.ps1 and windows10.ps1 exists and files not broken

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

Yet it works with the selected image.

image

Is there any clipboard logic change because of win 10 update?

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

Nope. Clipboard image uploading depends on windows10.ps1 and getClipboardImage and not change in recent releases.

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

you can run the script with your powershell:

notice the -xx below should use the option in getClipboardImage.ts

powershell -noprofile -xxx -xx -xx -file windows10.ps1 imagepath

And see what happened. I think it maybe the powershell's problem.

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

Ran this command and a binary file was generated. Is the parameter "imagepath" right?

image

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

hmmmmmmmmm, imagePath is a png image filename. Such as xxx.png

https://github.com/PicGo/PicGo-Core/blob/dev/src/utils/getClipboardImage.ts#L25

powershell -noprofile -xxx -xx -xx -file windows10.ps1 test.png

And you should capture a picture before running this script.

If a png file is generated, then the script is no problem and not a problem with picgo. So maybe it's the system permission issues

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

After a long time of consecutive debug grinding, I finally caught the root of this crash bug, which is the wrong use of PowerShell command.

According to page159 of Ed Wilson's Windows PowerShell 3.0 First Steps, a Microsoft Press book, it states that in order to keep the PowerShell console open you have to add parameter "-noexit" before running the PowerShell scripts. Screenshots are as follows.

image

image

In the case of picgo-core, the getClipboardImage.ts needs to read output from the PowerShell script execution, yet it is impossible to read output if the intrinsic PowerShell console close automatically after running windows10.ps1, so you need to add "-noexit". And in my debug grinding, you also need to comment "-windowstyle" and "hidden", although I still don't know the reason, it works eventually.

Here it is.

image

image

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

Will this change cause the powershell window to open explicitly?

It is expected that image uploading will be performed without disturbing the user. Is this consistent with the previous experience after adding this parameter?

And this script has always been normal before, that's wired.

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

Run in CMD and no PowerShell console will explicitly pops up.

In my guess, your acquiring the clipboard implementation from vs-picgo, which mainly takes advantage of the integrated CMD terminal of vscode, leads to the ignorance of use of picgo-core clipboard outside of vscode's integrated cmd terminal. Therefore, when Typora officially acquires picgo-core and provides documentation, this potential problem becomes apparent, because Typora users using picgo-core need to add custom command, and the custom command calls the native cmd, not integrated one, thus it does not behave like vscode's.

In vscode's integrated cmd terminal, it makes no difference to add '-noexit' or not, maybe for some customized mechanism.

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

Run in CMD and no PowerShell console will explicitly pops up.

In my guess, your acquiring the clipboard implementation from vs-picgo, which mainly takes advantage of the integrated CMD terminal of vscode, leads to the ignorance of use of picgo-core clipboard outside of vscode's integrated cmd terminal. Therefore, when Typora officially acquires picgo-core and provides documentation, this potential problem becomes apparent, because Typora users using picgo-core need to add custom command, and the custom command calls the native cmd, not integrated one, thus it does not behave like vscode's.

In vscode's integrated cmd terminal, it makes no difference to add '-noexit' or not, maybe for some customized mechanism.

Nice, if the user experience is the same as before, then I should merge your PR. Did you test in Typora?

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

CMD test result:

image

image

image

image

未命名图片

image

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

But it will block the console and will not exit?

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

Thanks for point out my ignorance of the cursor. Refer to this Stack Overflow problem and finally find a solution from Joe Johnston's comment.
How to exit PowerShell.exe inside of CMD
The right way to fix the bug is as follows.

#windows10.ps1 
function main{
      .....

      $imagePath
      # fix windows 10 native cmd crash bug when "picgo upload"
      # https://github.com/PicGo/PicGo-Core/issues/32
      Exit 1
}
execution = spawn('powershell', [
        '-noprofile',
        '-noninteractive',
        '-nologo',
        '-sta',
        '-executionpolicy', 'unrestricted',
        // fix windows 10 native cmd crash bug when "picgo upload"
        // https://github.com/PicGo/PicGo-Core/issues/32
        // '-windowstyle', 'hidden',
        // '-noexit',
        '-file', scriptPath,
        imagePath
      ])

from picgo-core.

Leslie-Wong-H avatar Leslie-Wong-H commented on August 14, 2024

CMD test result:

Before fix:

image

image

Then crashes.

After Fix:

image

image

from picgo-core.

Molunerfinn avatar Molunerfinn commented on August 14, 2024

Thanks for your contribution!

from picgo-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.