| <<<Back 1 day (to 2017/07/19) | 20170720 |
jtth | chrisl: sort out the stdio hooks kens talked about to see any errors/warnings gs emits. How? | 14:47.35 |
chrisl | jtth: https://www.ghostscript.com/doc/9.19/API.htm#set_stdio | 14:48.21 |
kens | You need to register callback functions with the DLL. Then the DLL will call those functions when it has something to send back | 14:48.25 |
jtth | kens: Ok. How to register callbacks? More specifically, how to for the gsapi_new_instance? (I'm assuming this is what I want info on as its returning fatal error) | 15:46.16 |
kens | You need to call gs_api_setstido, the srguments to that API entry point are the callback functions | 15:46.55 |
| Typical, our code doesn't call it | 15:48.27 |
chrisl | There are examples in the file I linked above | 15:48.41 |
kens | ah oops, I can't spell it seems | 15:48.51 |
jtth | Oh my apologies, my eyes drifted towards kens reply and I overlooked the reply&link you posted earlier Chris. | 15:49.13 |
| I will give this a look. | 15:49.16 |
kens | chrisl the examples all call gsapi_set_stdio *after* gsapi_new_instance | 15:49.42 |
| I'm not certain if its possible to do so before. Mind you, its worth trying | 15:50.01 |
| Ah, in fact you can't. | 15:50.10 |
chrisl | It's not - without a context, where can you store the pointers? | 15:50.18 |
kens | Because one of the arguments to set_stdio is the instance returned from new_instance | 15:50.26 |
| So given that its dying in new_instance, setting the callbakcs isn't feasible | 15:50.50 |
kens | is assuming its still the case that it fails in new_instance ? | 15:51.02 |
| Or did I miss something ? | 15:51.09 |
chrisl | No, I fixed that | 15:51.10 |
kens | Oh, well in that case.... | 15:51.18 |
chrisl | I would also note that the C# code from codeproject.com implements the stdio hooks.... | 15:53.18 |
jtth | So the problem now is with the c# code sourced from codeproject. Universal Windows Platform (or UWP) apps don't have access to all the APIs available on windows desktops. | 16:09.37 |
| See: https://developer.microsoft.com/en-us/windows/mixed-reality/current_limitations_for_apps_using_apis_from_the_shell | 16:09.39 |
| So I forgot that I had run into this before but there were a couple of things I had to change. Admittedly a huge oversight on my part. | 16:10.17 |
| I am not sure how the gsdll_stdin is normally used, but in the code I am using there's a piece that goes like, int ich = Console.Read() and console.read doesn't appear to be available to uwp apps. | 16:11.14 |
kens | Well you don't need to copy the whole project, I htink Chris was just pointing out that you could steal that bit too | 16:11.16 |
| You don't need to care about stdin, you can leave that one NULL | 16:11.42 |
jtth | True. | 16:11.42 |
| oh? | 16:11.47 |
kens | You aren't sending data to GS via stidn right ? | 16:11.59 |
| So you don't need to have it look 'somewhere else' when it expects data on stdin | 16:12.14 |
| stdout and stderr are the ones you are interested in | 16:12.29 |
jtth | Yeah I don't think it is being used, thats why I remember not worrying about that one | 16:12.32 |
kens | You do want the output channels though | 16:12.44 |
jtth | Those don't have anything I needed to change | 16:12.55 |
kens | Then you should be getting data sent back to the callbacks | 16:13.08 |
jtth | Ok I'm just not sure how to view this data I am getting back.... simple print statements? | 16:14.24 |
kens | well its just strings so yeah | 16:14.48 |
chrisl | That's up to you and you're environment | 16:14.53 |
kens | Or write to a log file, anythign really | 16:14.57 |
chrisl | s/you're/your | 16:15.04 |
| I'd assumed that a HoloLens app wouldn't be console appliation | 16:15.34 |
jtth | I can use Debug.Log statements (I believe), and I'm in VS2015. What data am I trying to look at, what stdout/stderr return? | 16:16.39 |
kens | Yes | 16:16.51 |
| THey should give you information about the failure (assuming there is one) | 16:17.04 |
jtth | StdioCallBack stdoutCallback = new StdioCallBack(gsdll_stdout); StdioCallBack stderrCallback = new StdioCallBack(gsdll_stderr); intReturn = gsapi_set_stdio(intGSInstanceHandle, stdinCallback, stdoutCallback, stderrCallback); | 16:25.24 |
| oh lord my apologies. | 16:25.28 |
kens | :-D | 16:25.35 |
jtth | https://pastebin.com/YaiBe8mY | 16:25.46 |
| So just print out what these return? | 16:26.01 |
kens | Yes | 16:26.07 |
| I must admit I'm not certain that will work, my C# (or even C++) doesn't reacxh that far | 16:26.55 |
kens | turns into a pumpkin and leaves the ball | 16:31.06 |
jtth | Ok giving these print outs a go. Crossed fingers. | 16:37.26 |
| chrisl: https://pastebin.com/X2iDHNfb | 16:46.10 |
| Completely unrelated q, how come your name appears red sometimes | 16:47.15 |
chrisl | jtth: maybe when my status is "away" | 16:48.02 |
| jtth: TBH, your pastebin means nothing to me, sorry | 16:48.40 |
jtth | Ha, ah I see. Please relay your thoughts on the output. Clearly I didn't print out what we were looking for... I don't think? | 16:48.48 |
| It just shows that I was trying to print whatever the callbacks were going to return | 16:49.22 |
| Im not sure what @kens and were talking about when I was to diagnose the callback information | 16:49.47 |
chrisl | That's not really how callbacks work - if I'm following you..... | 16:50.18 |
jtth | Mm. Ok. So I don't know how they work. I was trying to get at what exactly the data was that @kens was referencing | 16:50.47 |
chrisl | You need to define functions, and pass them as pointers into the library - the library will then call your functions via the pointers | 16:51.32 |
jtth | Sooo.... "The stdin callback function should return the number of characters read, 0 for EOF, or -1 for error. The stdout and stderr callback functions should return the number of characters written." | 16:51.39 |
| Are those the results I am looking for | 16:51.51 |
chrisl | No, your functions will be passed a pointer and a length - the pointer points to a string of the length | 16:52.34 |
| Look at example 2 here: https://www.ghostscript.com/doc/9.19/API.htm#Example_usage | 16:53.02 |
jtth | How do I pass them as pointers into the library | 16:53.13 |
chrisl | Using gsapi_set_stdio() | 16:53.34 |
| As shown in Example 2: https://www.ghostscript.com/doc/9.19/API.htm#Example_usage | 16:54.04 |
jtth | So this, intReturn = gsapi_set_stdio(gsHandle, incb, outcb, errcb); | 16:55.14 |
| Returned -100 again. What am I missing | 16:55.28 |
chrisl | The only way it returns an error is if gsHandle == NULL | 16:56.49 |
jtth | And when is gshandle null or what causes it to be | 16:58.28 |
| It is declared as, IntPtr gsHandle = IntPtr.Zero; | 16:58.55 |
chrisl | I've no idea what gshandle is | 16:58.56 |
jtth | Ha, his ping out time was 4min20sec. | 17:00.55 |
| I don't know what it is either tbh, the person who developed this code used it like such | 17:01.12 |
chrisl | I thought it was quiet..... | 17:01.14 |
jtth | The pointer to the current istance of the dll; IntPtr intGSInstanceHandle = IntPtr.Zero; | 17:02.28 |
| intReturn = gsapi_new_instance(out intGSInstanceHandle, _objHandle); | 17:02.38 |
| Not quiet sure how to diagnose how it is used other then it appears to be an integer pointer | 17:02.57 |
chrisl | Right, so the only way that can be null is if gsapi_new_instance() failes | 17:03.00 |
jtth | quite* | 17:03.02 |
chrisl | It's just a pointer, it's effectively opaque - it points to much more that an integer | 17:03.41 |
| Have you looked at the way the PDFConvert project implements the callbacks? That seems like a good place to start | 17:04.24 |
jtth | So it would appear this is all that exists calling that is this: https://pastebin.com/Gmt0Y1zM | 17:05.04 |
| Excuse my poor grammar there. The callbacks being out/err? | 17:05.34 |
chrisl | I'm not following your meaning.... | 17:06.54 |
| You much have a valid gs instance before you try to register callbacks with it | 17:07.24 |
| s/much/must | 17:07.54 |
jtth | So confused. I don't know how to tell if I have a valid instance other then intReturn. | 17:08.36 |
| I really want to get this working but I honestly cant debug a problem that I cant even find :( | 17:08.55 |
| s/cant/dont know how to | 17:09.49 |
| that being the first cant, not the second | 17:10.20 |
chrisl | So, in C terms, the first parameter to gsapi_new_instance() is a pointer to a pointer - I've no idea how that relates to C# | 17:11.46 |
| Okay, so the "out" modifier should take care of that | 17:12.55 |
| So, after the call to gsapi_new_instance() intGSInstanceHandle should not be null | 17:14.44 |
| And _objHandle *must* always be NULL | 17:15.32 |
jtth | It appears as if _objHandle = IntPtr.Zero as well | 17:26.05 |
| the problem with this that just flat out doesnt make sense is that the script works to perfection in the Unity Editor | 17:30.51 |
| so it must be a problem with the hololens access permissions for creating and deleting files | 17:31.09 |
chrisl | Creating the context doesn't access any files, it only allocates memory. And if the memory allocation fails, it returns the error | 17:34.36 |
jtth | That has to be it then. The Hololens must not have create/delete permissions at the location where it's trying to convert my pdfs into jpegs. | 17:44.45 |
| Well I am going to go ahead and drop this pipe dream of fixing it for the time being. Been on this pdf conversion for multiple weeks. | 17:45.27 |
| My advice. Dont develop dynamic apps for the hololens as its current restrictions to the windows api render it an absolute mess. | 17:46.03 |
| Not to mention when you develop using Unity you essentially have to develop every bit of code twice | 17:46.18 |
Robin_Watts | jtth: So you want to take PDFs in and get JPEGs out... | 17:49.48 |
chrisl | Hopefully, I'll get the WinRT build fixed in a non-hacky way, and usable on VS2015 and later - then you can build a debug DLL and follow the code into gs | 17:50.02 |
Robin_Watts | Do you need to get the jpegs stored on disc, or would in memory do? | 17:50.12 |
jtth | Robin_Watts: Yes. I have PDFs converting to JPG files in Unity working as of right now. | 17:51.35 |
| The script converts each page of the PDF to a single JPG file. These files are created dynamically at runtime, and then deleted when I "close" the PDF for viewing in the app | 17:52.14 |
Robin_Watts | right, so if we could get gs to pass the jpeg data to you without putting it on disc, would that help? | 17:52.55 |
jtth | Again, works great in Unity. Doesnt work on the Hololens. I dont follow your meaning on disc or in memory... as in the files are never written to the folder, rather just loaded in memory? | 17:52.58 |
| I would love to be able to answer that question with a definite answer but I am new to hololens dev. as of about a month, maybe longer. So I cant be sure. | 17:54.30 |
Robin_Watts | Well, it is possible to tickle gs so that it sends the data out via stdout, I think. | 17:54.58 |
| So if you are trapping stdout, you can collect the data yourself. | 17:55.18 |
| This would then mean that you'd be in control of writing any files from within your own code, which may be easier for you to debug. | 17:55.48 |
chrisl | If he could trap stdout, we'd have a better idea of what the problem is | 17:56.07 |
jtth | I dont even know how to trap, let alone what trapping a method means :-( | 17:57.00 |
Robin_Watts | jtth: OK, so dumb things to try: | 17:57.19 |
| 1) You are asking gs to write its output to a file 'foo/bar/baz.jpg'. Why not try creating that from your own code, just to see if you get an error. That would tell us whether that file location should be writable or not. | 17:58.14 |
| 2) Before you call gsapi_init_with_args, call gsspi_set_stdio with a set of functions to be called back to consume stdout/stderr etc. | 18:00.09 |
jtth | I will go ahead and try one first as I don't know how to go about 2 | 18:03.18 |
| Yeah, an UnauthorizedAccessException is thrown when trying to create files in the same directory that I am reading files from. | 18:13.03 |
| Let me find an 'approved' folder that the hololens can write to | 18:14.06 |
| Robin_Watts: yeah I can't get windows obnoxious folder pickers to work | 19:45.35 |
| https://docs.microsoft.com/en-us/windows/uwp/files/quickstart-managing-folders-in-the-music-pictures-and-videos-libraries | 19:46.51 |
| beyond me. so complicated to try and use this with gs | 19:47.05 |
| Forward 1 day (to 2017/07/21)>>> | |