Git Product home page Git Product logo

Comments (9)

filips123 avatar filips123 commented on June 9, 2024

I can also reproduce this error. It happens directly when launching the runtime. It seems to happen only when the CREATE_BREAKAWAY_FROM_JOB flag is set.

I don't know why that happens and how to fix it. It seems to be some weird problem with how Task Scheduler runs tasks.

from pwasforfirefox.

chaoscreater avatar chaoscreater commented on June 9, 2024

I've temporarily fixed the issue by adding my script to shell:startup folder. It runs on startup and PWAsForFirefox still works. It's not ideal, as I'd like to run via Task Scheduler for different reasons, but it will do for now. It would be great if the root issue can be addressed one day.

from pwasforfirefox.

filips123 avatar filips123 commented on June 9, 2024

Yeah, but I have no idea why this issue happens... I quickly searched if there are any issues with CREATE_BREAKAWAY_FROM_JOB and Task Scheduler, but I couldn't find anything related. Because of this, unfortunetely, I think I cannot really fix this issue.

from pwasforfirefox.

chaoscreater avatar chaoscreater commented on June 9, 2024

I'm not sure it's an issue with Task Scheduler specifically. I was able to replicate the issue when I ran my script using this tool:
https://www.sordum.org/8727/runastool-v1-5/

The tool runs my script, which then calls the runtime and I get the same problem.

from pwasforfirefox.

filips123 avatar filips123 commented on June 9, 2024

Now I think the problem is that Task Scheduler and RunAsTool do not set the JOB_OBJECT_LIMIT_BREAKAWAY_OK flag when creating a process job object, so then any child process that tries to create a new process with the CREATE_BREAKAWAY_FROM_JOB flag set will fail.

I don't know why they decided not to add this flag. Maybe it's for security, or that the whole task (including child processes) can be stopped, so no running processes are left.

I will check in the future if it's possible to detect when JOB_OBJECT_LIMIT_BREAKAWAY_OK is set and only apply CREATE_BREAKAWAY_FROM_JOB if that is the case. However, I don't know if launching the runtime will then actually work, or will the Task Scheduler also stop it.

from pwasforfirefox.

chaoscreater avatar chaoscreater commented on June 9, 2024

That would be great, thank you.

Alternatively, if you know of any methods that allows you to invoke the runtime in an automated way, please do let me know. I've tried a couple of things, such as using BATCH script, Powershell and AHK script, in combination with Task Scheduler and RunAsTool etc. They all invoke the runtime, but they don't work as it should.

The interesting thing is that if I run either a BATCH or Powershell script via Task Scehduler with elevated rights, then those scripts will run as administrator, which in turn invokes the runtime as administrator. When the runtime is invoked, it doesn't show any access is denied error, but also nothing happens. The runtime console window just flashes for a second and it goes away. I've tried to capture this process, but haven't had much luck.

The only working solution I have now is to either run a Powershell or BATCH script manually, or simply add the scripts to shell:startup and that gets run automatically on system startup, under my user context. This works well at the moment, except that it's sometimes not very consistent, because for some reason the entries under shell:startup can be missed and ignored. I've seen this happen once or twice in the past, which is why I've opted to use Task Scheduler as that is always 100% consistent and reliable.

from pwasforfirefox.

filips123 avatar filips123 commented on June 9, 2024

Alternatively, if you know of any methods that allows you to invoke the runtime in an automated way, please do let me know.

Well, if you enable "Launch this web app on system login" in the extension for a specific web app, it should automatically enable launching on login. However, it does this by copying a shortcut to shell:startup, so appearently it might not be completely reliable. But maybe it's unreliable because you are using a BATCH script? So, you can try if using this option (which makes a shortcut instead of a script) will make it more reliable.

If you want to change the start URL or other properties when launching, you can also do a similar thing manually by copying a shortcut from the start menu directory to shell:startup and then edit the shortcut with the new arguments.

I think another way to run apps on startup is to create an entry in the registry in the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run key. You can also try this, but I don't know if it works and how reliable it is.

The interesting thing is that if I run either a BATCH or Powershell script via Task Scehduler with elevated rights, then those scripts will run as administrator, which in turn invokes the runtime as administrator. When the runtime is invoked, it doesn't show any access is denied error, but also nothing happens.

It's probably still the same problem, but I don't know why the error doesn't show up.

from pwasforfirefox.

chaoscreater avatar chaoscreater commented on June 9, 2024

Well, if you enable "Launch this web app on system login" in the extension for a specific web app, it should automatically enable launching on login. However, it does this by copying a shortcut to shell:startup, so appearently it might not be completely reliable. But maybe it's unreliable because you are using a BATCH script? So, you can try if using this option (which makes a shortcut instead of a script) will make it more reliable.

When you add things to shell:startup (it doesn't matter what it is, it could be a Powershell script, BATCH script or Autohotkey script), it will just fail to launch sometimes. I've noticed that the more startup entries you add, the easier it is for the system to miss launching it. I'm not sure why, but it's not BATCH script specific.

Also, your suggestion won't work for me unfortunately. I'm not simply using your runtime to launch a static PWA. I'm using it to invoke a Teams deep-link. It looks something like this:

firefoxpwa.exe site launch "01HMZQPV062JSY2N2ER6VJXDHM" --url "https://teams.microsoft.com/_#/conversations/19:dfzzzzzzzz29-a587-51291370f921_f31xxxxxxxxxxxxxxx33-a10c-c692fa8bbxxxxxxxxxx7@unq.gbl.spaces?ctx=chat"

The deep-link URL is dynamic and I pass in this value via an automation script that I wrote. It works really well and I just need firefoxpwa to launch the PWA when this happens, but obviously I was running into the issue as per my original post.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

Ahh yes, I know about this one. I'll try to add my Autohotkey script there and see how it goes.

Alternatively, I think there are some apps that allow you to create a Windows service, which basically runs a process in the background. You can set the service to run automatically, so maybe I'll try that too.

In any case, the solution I'm using now (adding Autohotkey script to shell:startup and then invoking the runtime with a dynamically generated deep-link URL) is working fine. I think it's only about a 1~5% chance that the shell:startup entries will be ignored at startup, so it's not really a major problem.

from pwasforfirefox.

filips123 avatar filips123 commented on June 9, 2024

I fixed this in 2.12.0.

from pwasforfirefox.

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.