The Two Faces of JsRT (in Windows 10)

In terms of Windows 10, probably the biggest thing to happen to the JsRT APIs in Windows was the IE/Edge browser split.

For anyone who’s been living under a rock, Microsoft introduced a new browser in Windows 10 called Edge (neé Project Spartan). Edge basically represents a fork in the road for the web browser codebase at Microsoft: down one path the IE code will continue on, largely unchanged and preserving all that crufty backwards compatibility we all love to hate, and down another path will go Edge, discarding all the legacy shackles of IE and committing to a thoroughly modern browser experience.

And, just as the browser now splits into IE and Edge, so does the underlying JavaScript engine, Chakra. There are now two (yes, two!) JsRT APIs:

  • The “legacy” JsRT APIs that are exposed by jscript9.dll (the one that IE uses), have not changed since Windows 8.1, and will not be added to.
  • The “Edge” JsRT APIs that are exposed by chakra.dll (the one that Edge uses), have some breaking changes since Windows 8.1, and will be updated as the Edge browser moves forward.

You can find more details on the breaking changes that were made to the Edge JsRT on MSDN, but in a nutshell they are:

  • In C++ you #define USE_EDGEMODE_JSRT before including jsrt.h, and you link against chakrart.lib instead of jsrt.lib.
  • In C# and VB, you target your PInvoke declarations at chakra.dll instead of jscript9.dll.
  • The “version” parameter of JsCreateRuntime disappears (since there will only ever be one evergreen version of the Edge Chakra).
  • The debugging no longer requires an IDebugApplication. Thus, JsStartDebugging and JsCreateContext lose a parameter.

The last bullet point may seem a little odd and arbitrary. The reason is that the Edge version of the JsRT API is now supported as a part of the UWP (Universal Windows Platform). That means that a “modern” UWP application can host the Edge Chakra runtime and still qualify for the Windows Store (i.e. it won’t be rejected for using non-UWP APIs). To get there, though, the Chakra team needed to remove things that don’t work on the UWP, namely talking to the PDM (Process Debug Manager), which is what you need to get an IDebugApplication. Since it turns out in almost every possible case you don’t need to be able to supply your own IDebugApplication, Chakra now just acquires one on your behalf.

I’ve updated my chakra-host sample on GitHub to include samples that show hosting both “legacy” and “edge” JsRT on Windows 10. I’ve also added a new sample to the Windows Samples showing this. The Chakra team also now has a GitHub repo where they host their own samples.

You should also follow me on Twitter here.

4 thoughts on “The Two Faces of JsRT (in Windows 10)

  1. Michael

    Hello Paul,

    I looked at your chakra-host project and it seems to be a perfect match for a problem I’m currently trying to solve.

    I’m hosting a IE11-Webcontrol in a native desktop app. Now I want to use your chakra-host library to take snapshots of the JS-Heap to find potential memory leaks etc. But the problem is there seems to be no way to access the JsRuntimeHandle from the embedded browser programmatically. I scanned through the trillion COM-Interfaces but didn’t find anything suitable. I also thought about getting it indirectly using JsGetCurrentContext in a native function that is called from JavaScript but this doesn’t seem to be possible.

    Is this simply impossible or do you have any idea how to do this ?


    1. paulvick Post author

      Hi Michael!

      Unfortunately, IE11 uses a different method of hosting Chakra that is not compatible with JsRT. You won’t be able to access JsRT on the same thread as a IE11 WebControl that’s hosting Chakra, and you can’t (to the best of my knowledge) pass handles between JsRT and IE11. Sorry about that!


      1. Michael

        Hi Paul,

        thank you for the fast answer, I already suspected that it is impossible. A followup question: are there any plans to use Edge instead of IE11 as the embedded browser in a native desktop app ?


        1. paulvick Post author

          Hi Michael!

          Unfortunately, there aren’t any plans that I know of to do this, although I am not privy to what might be done by the IE team!



Leave a Reply

Your email address will not be published. Required fields are marked *