-
Notifications
You must be signed in to change notification settings - Fork 85
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
App crashing #28
Comments
Another one It happened when the task ran the second time. However it's not consistent. The task code looks like this right now: var gitTask = MacGap.Task.create('/bin/ls', this.gitTaskComplete);
gitTask.arguments = ['/Users/jeffh/Desktop'];
gitTask.pipeOutput = true;
console.log(gitTask);
gitTask.launch(); I wonder if it's the console.logging of the gitTask object? |
You can see what I'm trying to do from line 34 at https://github.com/MacGapProject/documentation-app/blob/master/public/models/pageModel.js |
The bad access exceptions are happening because whatever you're trying to call/access has already been released from memory and no longer exists. It's probably because you're trying to make a subsequent call to the task. NSTask is a single use object, once it's been launched it cannot be launched/used again and will throw exceptions if you try to access methods or interact with the task again. Like I mentioned before, if you're trying to do complex stuff with NSTask, you're going to have to do it in Obj-c, not with the MacGap Task command as there's just entirely too many variables to account for. I'm honestly not entirely sure why you would even need to use NSTask for a documentation app anyway? It looks like you're wanting to use 'git', but git isn't installed on OSX by default, so the whole app would be unusable if you're relying on that and someone didn't have git installed. |
Thanks so much for looking into this. Do you have a sample piece of code for the task command and new pipeOutut that shows it working? I can't see anything that I'm doing wrong and I've tried to create the simplest case I can think of ( It does only happen when I reload the page inside the MacGap window without restarting the app. Regarding the docs app, I'd like it to work offline because a) I'm often offline and b) I'd like to break any concept that MacGap is a glorified Fluid app equivalent (i.e. only useful to wrap around a page pulled live from the web). I'm also trying to demo as many of the commands as I can, so I had the notion that I could demo the task command to use git to pull in the repo on each app launch, thereby keeping everyone's docs up-to-date. I've bundled a git binary into the app. In terms of the actual commands it should be pretty trivial. |
This code works fine:
It should return an object with the stdOut of "MG.app" or similar. Setting the 'environment' like you are doing isn't correct, the environment property of NSTask is for setting/adjusting environment variables, which you don't need to do since the task inherits the callers environment, i.e. your app. The main issue you're going to run into is that piping the output is, for the most part useless. This is because whatever the output happens to be, it has to be converted to a string to be returned to javascript. So with the ls example, if you run it in a directory with multiple files, it just returns a string representation of the contents, i.e. "file.txt↵file2.txt↵something.js↵index.html" etc. It doesn't really do you any good. |
Thanks for this — I'm still playing with it, but was hoping you could explain one aspect for me. I'm trying to understand how the properties work when there is more than one task instantiated from JS. For example, at face value it looks like |
Would it possible to simplify the API? I'm thinking that var myTask = MacGap.Task.create('/bin/ls',function(results) {
console.log(results);
});
myTask.pipeOutput = true;
myTask.launch(); instead could be something like var myTask = MacGap.execute('/bin/ls', function(stdout) {
console.log(stdout);
}); Drawing inspiration from e.g. http://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback and the just released Javascript Actions API for Launchbar: http://www.obdev.at/resources/launchbar/developer-documentation/javascript-launchbar.html#//apple_ref/cpp/Method/execute Launchbar has some interesting stuff in their API, e.g HTTP: http://www.obdev.at/resources/launchbar/developer-documentation/index.html#LaunchBarJavaScriptReference |
It's a good point — I've moved this to a new issue as it's unrelated to the app crashing one. |
True, thanks. Moved HTTP to #30 |
I haven't quite worked out how to reliably replicate it, but my MG2 app (actually the MG2 Documentation App) crashes quite a lot. I'm not sure what's most useful out of the crash log, or should I post the whole thing?
Here's the start of my most recent one. Or get the full thing
The text was updated successfully, but these errors were encountered: