Skip to content
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

Unable to move the cache, Unable to create cache #113

Open
GhostInTheMachines opened this issue Jun 2, 2016 · 32 comments
Open

Unable to move the cache, Unable to create cache #113

GhostInTheMachines opened this issue Jun 2, 2016 · 32 comments

Comments

@GhostInTheMachines
Copy link

When starting a debug session with Ctrl + Shift + R the Chrome application opens properly but a ton of errors pop up in the Sublime console. I have tried creating the test script in different folders but the errors are the same:

[5728:8960:0602/155257:ERROR:cache_util_win.cc(20)] Unable to move the cache: 0
[5728:8960:0602/155257:ERROR:cache_util.cc(134)] Unable to move cache folder C:\Users\dkimble\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache to C:\Users\dkimble\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GPUCache_000
[5728:8960:0602/155257:ERROR:cache_creator.cc(129)] Unable to create cache
[5728:8960:0602/155257:ERROR:shader_disk_cache.cc(589)] Shader Cache Creation failed: -2
[Finished in 0.3s]

@danmoseley
Copy link
Collaborator

danmoseley commented Jun 6, 2016

Sometimes the browser emits stuff like this due to bugs and there’s no way to know that it can be safely filtered out.

If it’s not appearing in the chrome console then either it’s filtering it out by itself (which would be odd) or there’s something slightly different in how Sublime is launching the browser, eg., the working directory or permissions or a concurrent browser session, or ??.

You could try just deleting C:\Users\dkimble\AppData\Local\Google\Chrome\User Data\ShaderCache

@GhostInTheMachines
Copy link
Author

GhostInTheMachines commented Jun 7, 2016

I had a little trouble deleting the ShaderCache and I discovered that it is because Chrome leaves a half a dozen processes running even after I close it.

Once I disabled all of the extensions inside Chrome the error messages went away.

However, now instead of opening the html file that I am trying to debug, I get a directory listing inside of C:\Program Files (x86)\Application\50.0.2661.102\

Any ideas why it would be looking for the html file here? If SWI was passing the proper port, it should redirect to my XAMPP directory root. Even after I turn the Apache server off and clear the cache in the browser, Chrome still opens up C:\Program files file when I run SWI

I noticed that when I start the debugger there is no port listed. Can I edit this somewhere? I have included a screenshot of the sublime interface when I start the debugger.

sublimeswicapture01

@danmoseley
Copy link
Collaborator

You can change the port with the chrome_remote_port setting. In your user settings JSON, add
"chrome_remote_port": "12345"

I seem to remember some bug of this sort in the past, and it might have been related to quoting in the command line we use to start Chrome. After this point, you'd have to debug.

Incidentally you can edit this line to start logging the websocket traffic -- but your problem sounds upstream of that: websocket.enableTrace(False)

@danmoseley
Copy link
Collaborator

By using a tool like sysinternals.com Process Explorer, you can perhaps right click on the chrome.exe process and see the original command line that launched it. That might give a clue. If you look at the function SwiDebugStartChromeCommand you can see what it's supposed to be doing.

@GhostInTheMachines
Copy link
Author

GhostInTheMachines commented Jun 8, 2016

I believe I see where the problem is but I am not quite sure how to fix it. If I use the menu inside the editor to open up swi.sublime-settings the file is empty and if I try to edit the file and save it I get an error stating that it cannot find the path.
However, if I use the menu inside the editor to "browse packages" then open the folder "SublimeWebInspector" and then right click the "swi-sublime-settings" file to open with Sublime Text, I will find all of the Chrome settings inside this file.

To me this looks like there must be a path setting inside of the SWI settings somewhere that needs to be changed. It might have something to do with the fact that I had Sublime Text 2 prior to this but I can't be certain.

I have opened up the swi.py file to see where the port value is read from. I can see that it gets set by calling the function utils.get_setting('chrome_remote_port'). My question now is if this is being read from the swi.sublime-settings file (included in the screenshot below) and this file is in the same directory as the swi.py application, why is the value not being properly set?,
swi screenshot

@danmoseley
Copy link
Collaborator

There are two settings files, one is the package settings (which has lots of defaults as you see) and the other is the user settings (which is empty by default). These are both at Preferences>Package Setttings>Web Inspector>Settings - Default || Settings - User. You'll want to edit the latter to add your port, or override the chrome_path, or whatever else you need to do. Does that help?

@GhostInTheMachines
Copy link
Author

yes, as you can see from the first screenshot below I set the port in the SWI user settings by going to Menu-->Preferences-->Package Settings-->Web Inspector--Settings user. However the default settings when I select Menu-->Preferences--Package Settings - Web Inspector --> Settings default opens a blank page which you can see in the second screenshot with the Orange Highlight which means it is starting a new file because no swi.sublime-settings file was found for the default.

However, the original screen shot I provided in my last post shows the swi.sublime-settings file that I opened by going to Menu --> Preferences-->Browse Packages which opens up a file explorer window which allows me to right click the swi.sublime-settings file which I am assuming is what should be getting opened when I use the previous steps to select it from the menu. I think this means that the file is not getting recognized by SWI for some reason but as you can see from the screenshot below it should be getting a port from the user settings file.
swiusersettings

below is the blank default settinss accessed from inside the editor
swidefaultsettings

@danmoseley
Copy link
Collaborator

I think the next step is to debug. Unfortunately it looks like I didn't document in the wiki here how to do that. From memory,

  1. Install the Python tools -- I had a good experience with Visual Studio, and it's free.
  2. Uninstall SWI, or physically remove it from %appdata%\Sublime Text 3\Installed Packages
  3. Clone the repo
  4. Run update.bat -- fix the path to your repo.
  5. Reopen Sublime. It should see SWI as if you installed it, but now it's running from the loose files copied from your repo.

If I remember correctly, you should now be able to attach from VS -- be sure to choose the Python debugging engine in the Attach dialog.

@GhostInTheMachines
Copy link
Author

GhostInTheMachines commented Jun 10, 2016

I followed the suggested steps and now I have a new repo cloned inside the packages folder.

I created a new Python project in VS, opened the swi.py file and set the port to a static value just as an experiment. The first time I tried an integer but ST3 would not open SWI so I assigned the port variable to a string value of "8082" which is the port my local Apache server is listening on.

At this point SWI will open the Chrome browser but still using the programs directory at file:///C:/Program%20Files%20(x86)/Google/Chrome/Application/51.0.2704.84/

@danmoseley
Copy link
Collaborator

danmoseley commented Jun 20, 2016

@GhostInTheMachines apologies for missing your post. Somehow I got one in email that I don't see listed here. You said

Okay, I think I have all of these steps completed. I cloned the ST3 repo inside of VS and I have it showing up in the VS2015 team explorer. From this point, do I need to open an sln file or should I create a new branch and then start a new project?

It looks like I didn't add a .sln file to the repo. You could create your own and add the .py files to it, or just open the .py files of interest directly, without creating a .sln yourself.

I am not sure what you are saying when you say "attach from VS using the Python debugging engine"

Start Sublime. You might have to run the plugin once. In VS, do Debug>Attach and find pluginhost.exe. This is the process that Sublime runs plugins inside. In "Attach With" box on that dialog, make sure you select "Python" and nothing else. Hit Attach. (If Python does not appear, re-run VS setup and select Python tools. Then try again.)

I opened Sublime Text 3 after cloning the repo but I am not sure how to validate that it is using the loose files from the repo.

If you had uninstalled the plugin using package manager, then "installed" it with update.bat (per steps 2 and 4 above) it should be present in %appdata%/sublime text 3/packages/web inspector as loose files, and NOT present in %appdata%\Sublime Text 3\Installed Packages (where the package manager would place it as a zip). If at this point it works within Sublime, you are successfully using it from the loose files. I don't recommend that you clone to that location, but instead run update.bat whenever you change your repo. Does that help?

Incidentally, when you run update.bat it is not strictly necessary to close Sublime first. If you open the Sublime console with "Ctrl-`" (ctrl-tick) you will see it detect your change and reload the plugin. This usually works -- however if you have changed global code, I think it is necessary to reopen Sublime in order to cause the plugin to re-initialize completely. Along similar lines, if you make a change, run update.bat, and do not see your change, check the Sublime console for error messages or call stack traces.

@danmoseley
Copy link
Collaborator

Incidentally, I greatly appreciate your efforts here -- I will have no time to work on this for the foreseeable future, and I believe that is true of the only other contributor @sokolovstas. It's not difficult to work on the code, it's just fiddly to get set up. Also, the reason I put this aside was partly that it was working really well and the code was clean, so it's an appealing codebase to make changes to.

@danmoseley
Copy link
Collaborator

When program files appears in the browser, it's because we passed empty quotes to launch Chrome, ie.,

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 ""

instead of

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222

You can see this command line in the Properties for the root chrome.exe in process explorer.

The run function needs debugging to see why it's doing this.

@danmoseley
Copy link
Collaborator

One other note -- I think if you launch Chrome yourself (including the debugging port flag) you should be able to attach with Web Inspector and avoid the launch problem. From that point on, you can refresh the page when you need to update it.

@GhostInTheMachines
Copy link
Author

I ran the process explorer and it looks like you are correct that it is running the command with an empty string as shown here:
processexplorerchrome

@GhostInTheMachines
Copy link
Author

I followed the instructions above to attach the VS debugger to the pluginhost.exe process and I believe I am ready to debug.
Where should I set the breakpoint to start stepping through the code?

@danmoseley
Copy link
Collaborator

Awesome. You probably want to put a breakpoint in SwiDebugStartChromeCommand.run() as that's where the command is constructed.

You might be surprised by how straightforward the code is - most of it maps to individual user commands. You'll quickly become familiar.

@GhostInTheMachines
Copy link
Author

It seems that I have a strange new problem now. I was ready to get some debugging done this morning and I fired up ST3, ran SWI, attached to plugin_host.exe and the VS status bar changes to active for about three seconds and then exits out of the debugger with the following error:

The program '[11052] plugin_host.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

pluginhosterror

I tried to close all the applications and start again but I seem to get the same result

@GhostInTheMachines
Copy link
Author

Incidentally, I have also been getting this other error when I run SWI the first time.
chromereadwriteerror

@danmoseley
Copy link
Collaborator

For the AV -- strange. Do you have the latest version of Sublime?

Do you have the latest version of the Python tools for Visual Studio? Check Tools>Extensions and see if there's an update.

It's possible that Dev15 might fix this, but that'd take a while to install and I'm just hypothesizing.

@danmoseley
Copy link
Collaborator

danmoseley commented Jun 27, 2016

For "Failed to Create Data Directory" - try putting "chrome_profile" in your plugin settings, and set it to some arbitrary string. That should trigger the code below in swi.py to add user-data-dir parameter which should cause it to not conflict with the regular chrome up.

         profile = utils.get_setting('chrome_profile') or '' 
167         if profile: 
168             profile = '--user-data-dir=' + profile 
169             cmd.append(profile) 

@GhostInTheMachines
Copy link
Author

Here is a screenshot of what my SWI user settings are now. Looks like the chrome_profile says default now, should I put something other than default?
swi_user_settings

@danmoseley
Copy link
Collaborator

It looks like this works around it:

"chrome_profile": "C:\\Users\\YOUR USER NAME\\AppData\\Local\\Google\\Chrome\\User Data\\foo"

It used to be possible to just put "foo" or some arbitrary string, but it now seems to make that relative to its install path, where it can't normally write. Perhaps a break in Chrome? Meantime, the above keeps it quiet for me.

@danmoseley
Copy link
Collaborator

If this is the issue, pending a Chrome fix, we need a change to swi.py at the point I pasted below, to (on Windows) prepend something like the above.

@GhostInTheMachines
Copy link
Author

GhostInTheMachines commented Jun 29, 2016

OK, I am now attached to the plugin_host.exe process so it seems that now I can just hit F11 to start debugging. It looks like I am getting an exception right at the import statements where it can not find a module named sublime. Is this a file that I am missing?
I copied the exception to the clipboard from VS and I am including a screenshot of the command window that pops up:

ImportError was unhandled by user code
Message: No module named 'sublime'

import error

@danmoseley
Copy link
Collaborator

Hmm, that's just broken. I verified with the latest Sublime and Chrome on Windows, with Visual Studio 2015 Update 2, debugging works fine for me.

%appdata%\Sublime Text 3\Installed Packages does not contain Web Inspector, right? it's only in ...Sublime Text3\Packages\Web Inspector.

Anything odd about your %PATH% ? I'd almost be tempted to remove Sublime (back up your settings) and remove the Sublime Text 3 folder then reinstall. Since it works for me, they haven't renamed their "sublime" package (which would be strange anyway) so something is wrong with the context in which Sublime is loading packages for you.

@GhostInTheMachines
Copy link
Author

OK, I used the package manager to remove SWI from ST3, I cloned a new copy of the repo and ran update.bat I want to double check that I am doing the debug correctly so here are the steps I took.

  1. Started a new project from inside VS using the following options:
    Python --> From Existing Python code (using all the other default settings) --> next
    Choose which file to run when F5 is pressed (I choose swi.py) --> next --> Finish
    config.py is bold in the solution explorer so I right click swi.py and set it to the startup file
  2. Changed .gitignore to ignore all C# and sln file extensions
  3. Set breakpoint inside of VS in the swi.py file at line 151 SwiDebugStartChromeCommand()
  4. Started ST3, opened a html file with JavaScipt script tags
  5. Attach VS to plugin_host.exe
  6. Used Ctrl + Shift + R to invoke SWI (one option comes up "Start Google Chrome with Remote Debug Port None)
    This is where I am expecting VS to stop at the breakpoint that I have set but instead the Chrome window opens in the programs directory just like it has all along.
  7. At this point I go over to VS and Click on the Debu menu to see if I have a step into option ( I don't it is greyed out,)

Usually when I am debugging something I have a main executable so it is a little unclear how I initiate the debugging process for a plugin which looks like it is just a set of class files.

I can see I am missing something here, but I am not sure what it is at this point
Trying to initiate this whole process from VS just gets me a console window like this one which goes nowhere since after pressing "any key" the debug process just ends.
f5_result

Trying to initiate the process by pressing F10 will let me step through the code until I get to the import sublime statement and then I get the exception that I originally posted but will post again here for convenience.

f10_result

@danmoseley
Copy link
Collaborator

The only things I do differently

  • I don't usually have a project open. I just open swi.py directly, then attach.
  • I sometimes hit "break" before doing the repro -- ie., I don't necessarily set a breakpoint. But it does hit breakpoints for me. You could try sprinkling them liberally.

For the "import sublime" issue, if it can't be ignored, I can only suggest asking on https://forum.sublimetext.com/ ... I can't repro myself.

Let me know how it goes.

@danmoseley
Copy link
Collaborator

Another thought about "import sublime" -- reduce the package down to the bare minimum -- I've not made a Sublime plugin from scratch but it might simply mean empty the folder down to just swi.py, and edit swi.py down to just that line. See if it still has the problem.

Another similar approach - get a sample Sublime plugin, and see if it hits it. Do they now expect you to invoke it by some othe rname than "sublime"?

@GhostInTheMachines
Copy link
Author

This time I navigated to the Sublime Text 3 --> Packages --> SublimeWebInspector folder and right clicked the swi.py file and used "open with" to open the file in VS 2015 and received this error box:
vs15error0702

@GhostInTheMachines
Copy link
Author

GhostInTheMachines commented Jul 2, 2016

Question: After attaching to plugin_host.exe do you start debugging by initiating SWI from inside ST3 or do you just hit F10 in VS15 and start stepping through swi.py?

After I attach to plugin_host.exe the stepping option in VS2015 is greyed out.

@GhostInTheMachines
Copy link
Author

I found the following errors in the ActivityLog.xml which look like they are related to the PythonTools plugin so I am going to try uninstalling and the re-installing PT. Also I am running VS 2015 update 3 and you are running update 2 so I don't know if that has something to do with this or not

2016/07/03 10:03:52.166
Error
Editor or Editor Extension
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.PythonTools.Extensions.GetAnalyzer(ITextBuffer buffer, IServiceProvider serviceProvider) at Microsoft.PythonTools.PythonClassifier..ctor(PythonClassifierProvider provider, ITextBuffer buffer) at Microsoft.PythonTools.PythonClassifierProvider.GetClassifier(ITextBuffer buffer) at Microsoft.VisualStudio.Text.Classification.Implementation.ClassifierTaggerProvider.<>c__DisplayClass12_01.&lt;CreateTagger&gt;b__0(IClassifierProvider provider)&#x000D;&#x000A; at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InvokeEligibleFactories[TExtensionInstance,TExtensionFactory,TMetadataView](IEnumerable1 lazyFactories, Func2 getter, IContentType dataContentType, IContentTypeRegistryService contentTypeRegistryService, Object errorSource)</description> </entry> <entry> <record>392</record> <time>2016/07/03 10:03:52.197</time> <type>Error</type> <source>Editor or Editor Extension</source> <description>System.NullReferenceException: Object reference not set to an instance of an object.&#x000D;&#x000A; at Microsoft.PythonTools.OutliningTaggerProvider.OutliningTagger..ctor(PythonToolsService pyService, ITextBuffer buffer)&#x000D;&#x000A; at Microsoft.PythonTools.OutliningTaggerProvider.CreateTagger[T](ITextBuffer buffer)&#x000D;&#x000A; at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator1.GatherTaggers(ITextBuffer textBuffer)


393
2016/07/03 10:03:52.293
Error
Editor or Editor Extension
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.PythonTools.Extensions.GetAnalyzer(ITextBuffer buffer, IServiceProvider serviceProvider) at Microsoft.PythonTools.Extensions.GetAnalyzer(ITextView textView, IServiceProvider serviceProvider) at Microsoft.PythonTools.Intellisense.IntellisenseControllerProvider.TryCreateIntellisenseController(ITextView textView, IList1 subjectBuffers)&#x000D;&#x000A; at Microsoft.VisualStudio.Language.Intellisense.Implementation.IntellisenseManagerConnectionListener.&lt;&gt;c__DisplayClass8_1.&lt;SubjectBuffersConnected&gt;b__1(IIntellisenseControllerProvider provider)&#x000D;&#x000A; at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata,TExtensionInstance](Object errorSource, Lazy2 provider, Func`2 getter)

@danmoseley
Copy link
Collaborator

If you get those still after your repair/reinstall, let me know and I'll ask the Python folk internally. Both of them look like they are related to the Python editor, so perhaps not necessarily breaking debugging.

For your question: I normally attach, then either set a BP or hit the pause button, then go to Sublime and trigger the plugin (ctrl-shift-R on my machine) so that its Python starts to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants