Quantcast
Channel: ClearScript
Viewing all 2297 articles
Browse latest View live

New Post: Global window object


New Post: Global window object

$
0
0
I think there should be anything about the HostItemFlags in the tutorial!

New Post: Problem dealing with arrays in VBScript

$
0
0
I've come across this same issue. Would it be possible to implement support for this? I'm trying to migrate away from the MS Script Control (used as an ActiveX control in .NET) to ClearScript using VBScriptEngine, and everything is working perfectly apart from this one issue. There are already customer scripts out there that expect to be able to receive arrays in VBScript from the host application, so we need to be able to preserve that behaviour.

Basically I would like to be able to call:

object[] array = new object[] { ...... };
engine.Script.MyFunction(array);

and have "array" pass through to VBScript properly.

I'm also having problems trying to access a C# function from VBScript that returns data through an array. I can do the following in MSScriptControl, but not with ClearScript:

Dim x
Dim y
funcs.GetArray x, y

public void getLogData(ref dynamic x, ref object y)
{
x = new int[5];
y = 10;
}

It's the "ref" that ClearScript seems not to like. Is this a particularly difficult problem to solve?

Thanks very much for the great work on ClearScript, it's a fantastic bit of software!

New Post: Release schedule?

$
0
0
Hi ClearScript,

Could you share any info on your next version release date?

Thanks,
Max

New Post: Release schedule?

$
0
0
Hi Max,

We're currently wrapping up Version 5.3.12, but we don't have a release date to share. Are you awaiting a particular new feature or bug fix?

Cheers!

New Post: Global window object

$
0
0
Hi again,

Please be aware that the HostItemFlags.GlobalMembers feature is quite expensive. It requires the script engine to call back to the host for all global property access, and that's a performance killer for V8, at least in scenarios that require fast access to global properties.

Support for this feature is enabled by default in order to maintain API compatibility, but we recommend that performance-critical applications disable it by using V8ScriptEngineFlags.DisableGlobalMembers. Of course, if you do that, you'll have to use a different technique to expose host methods at the global level.

Cheers!

New Post: Release schedule?

$
0
0
Additional features and bugs fixes is one of the reasons, but another one is to go through some legal approvals before I could use a library for the project I'm working on. That process takes time on my end, so I just want to make sure I don't have to do it twice if the new ClearScript version is just around the corner.

New Post: Problem dealing with arrays in VBScript

$
0
0
Hi orudge,

Thanks for your kind words!

When it comes to running existing VBScript code that relies on certain features of classic ActiveX embedding, ClearScript is definitely missing a few things. It was originally designed to make it easy to add scripts to existing hosts, not vice versa :)

Nevertheless, native array marshaling is something we're investigating as a global option, similar to WindowsScriptEngineFlags.MarshalDecimalAsCurrency. Do you think that would suffice?

The second part of your question deals with methods that have output parameters. ClearScript provides a way to invoke such methods from script code; there's a sample on the home page. Unfortunately it requires the use of ClearScript-specific "host variable" objects.

It might be possible to work around both issues with a translation layer. For example, if a script function takes a script array, call it through a wrapper that knows how to convert host arrays. If you must provide a host API that supports VBScript's ByRef semantics, create a VBScript pass-through that knows how to invoke the appropriate method using host variables.

Would something like that be feasible?

Cheers!

New Post: Problem with arrays in javascript (v8)

$
0
0
Not sure if I should post this as an issue, or it belongs here.

I'm using ClearScript to render pages (using handlebars), and seem to have a problem when iterating array in javascript (again, using handlebards).

Are the arrays not really arrays? If I iterate (using handlebars' #each), it looks like I get the elements in the array (as I should) and methods/properties of the array, or at least that's my guess.

Any input?

New Post: Problem with arrays in javascript (v8)

$
0
0
Hello, and thanks for your question!

It looks like you're asking about host (.NET) arrays rather than JavaScript arrays. Is that correct?

ClearScript's general approach is to avoid data conversion and provide full access to .NET objects. There are exceptions, mainly numbers and strings, but host arrays are exposed "as is"; that is, they are not converted to script arrays.

Normally ClearScript exposes the members of a host object (fields, properties, and methods) as properties of the corresponding JavaScript "proxy" object. Additionally, if a host object implements IList, as arrays do, ClearScript also exposes its valid indices, enabling JavaScript's familiar foo[123] syntax for element access.

So yes, if you use JavaScript's for...in statement to iterate over a host array, you'll get both its elements and its members, and it does appear that Handlebars's each helper works this way.

Consider applying the each helper not directly to a host array but to the output of a conversion function:
function convertArray(hostArray) {
    var result = [];
    for (var i = 0; i < hostArray.Length; i++)
        result.push(hostArray[i]);
    return result;
}
Another possibility might be to override the built-in helper with one that supports host arrays.

Cheers!

Created Unassigned: AccessViolationException while calling Dispose on V8ScriptEngine from a Finalizer [51]

$
0
0
Hi,
I am getting an AccessViolationException while calling V8ScriptEngine from a finalizer.
I can reproduce the issue with below code:
____________________________________________________________________________________
```
namespace ClearScriptLoadTest
{
public class ClearScriptWrapper
{
private Microsoft.ClearScript.V8.V8ScriptEngine v8Engine;
public ClearScriptWrapper()
{
this.v8Engine = new Microsoft.ClearScript.V8.V8ScriptEngine(Microsoft.ClearScript.V8.V8ScriptEngineFlags.None);
}
~ClearScriptWrapper()
{
Console.WriteLine("Finalizer called");
v8Engine.Dispose();
}
}


class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 1000000; i++)
{
ClearScriptWrapper csObj = new ClearScriptWrapper();
GC.Collect();
}
}
}
}

```

____________________________________________________________________________________

__Exception :__

Unhandled Exception: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory is corrupt.
at RefCount.Increment(RefCount* )
at SharedPtr<V8Context>.=(SharedPtr<V8Context>* , SharedPtr<V8Context>* that)

at Microsoft.ClearScript.V8.V8ContextProxyImpl.~V8ContextProxyImpl()
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean A_0)
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose()
at Microsoft.ClearScript.V8.V8ScriptEngine.Dispose(Boolean disposing)
at Microsoft.ClearScript.ScriptEngine.Dispose()
at ClearScriptLoadTest.ClearScriptWrapper.Finalize() in c:\Users\xxxxxx\Doc
uments\Visual Studio 2013\Projects\ClearScriptLoadTest\ClearScriptLoadTest\Progr
am.cs:line 18

It works fine when dispose is deterministic .

regards
```
skpandey
```

Commented Unassigned: AccessViolationException while calling Dispose on V8ScriptEngine from a Finalizer [51]

$
0
0
Hi,
I am getting an AccessViolationException while calling V8ScriptEngine from a finalizer.
I can reproduce the issue with below code:
____________________________________________________________________________________
```
namespace ClearScriptLoadTest
{
public class ClearScriptWrapper
{
private Microsoft.ClearScript.V8.V8ScriptEngine v8Engine;
public ClearScriptWrapper()
{
this.v8Engine = new Microsoft.ClearScript.V8.V8ScriptEngine(Microsoft.ClearScript.V8.V8ScriptEngineFlags.None);
}
~ClearScriptWrapper()
{
Console.WriteLine("Finalizer called");
v8Engine.Dispose();
}
}


class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 1000000; i++)
{
ClearScriptWrapper csObj = new ClearScriptWrapper();
GC.Collect();
}
}
}
}

```

____________________________________________________________________________________

__Exception :__

Unhandled Exception: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory is corrupt.
at RefCount.Increment(RefCount* )
at SharedPtr<V8Context>.=(SharedPtr<V8Context>* , SharedPtr<V8Context>* that)

at Microsoft.ClearScript.V8.V8ContextProxyImpl.~V8ContextProxyImpl()
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean A_0)
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose()
at Microsoft.ClearScript.V8.V8ScriptEngine.Dispose(Boolean disposing)
at Microsoft.ClearScript.ScriptEngine.Dispose()
at ClearScriptLoadTest.ClearScriptWrapper.Finalize() in c:\Users\xxxxxx\Doc
uments\Visual Studio 2013\Projects\ClearScriptLoadTest\ClearScriptLoadTest\Progr
am.cs:line 18

It works fine when dispose is deterministic .

regards
```
skpandey
```
Comments: Hi skpandey, Accessing another managed object from a finalizer is generally problematic. According to the [documentation](http://msdn.microsoft.com/en-us/library/system.object.finalize(v=vs.110).aspx) (emphasis added): ​ >The Object.Finalize method does nothing by default, but you should override Finalize only if necessary, and __only to release unmanaged resources__. ​ Additionally: ​ >The finalizers of two objects are not guaranteed to run in any specific order, even if one object refers to the other. That is, if Object A has a reference to Object B and both have finalizers, Object B might have already been finalized when the finalizer of Object A starts. ​ What's happening is that, in some cases, `ClearScriptWrapper` is finalized _after_ `ClearScriptWrapper.v8Engine`. This results in the latter being _resurrected_, and it can't handle that. We'll add the appropriate defensive checks, but our recommendation would be for your wrapper to implement the [dispose pattern](http://msdn.microsoft.com/en-us/library/b1yfkh5e(v=vs.110).aspx). Thanks for reporting this!

Edited Issue: AccessViolationException while calling Dispose on V8ScriptEngine from a Finalizer [51]

$
0
0
Hi,
I am getting an AccessViolationException while calling V8ScriptEngine from a finalizer.
I can reproduce the issue with below code:
____________________________________________________________________________________
```
namespace ClearScriptLoadTest
{
public class ClearScriptWrapper
{
private Microsoft.ClearScript.V8.V8ScriptEngine v8Engine;
public ClearScriptWrapper()
{
this.v8Engine = new Microsoft.ClearScript.V8.V8ScriptEngine(Microsoft.ClearScript.V8.V8ScriptEngineFlags.None);
}
~ClearScriptWrapper()
{
Console.WriteLine("Finalizer called");
v8Engine.Dispose();
}
}


class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 1000000; i++)
{
ClearScriptWrapper csObj = new ClearScriptWrapper();
GC.Collect();
}
}
}
}

```

____________________________________________________________________________________

__Exception :__

Unhandled Exception: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory is corrupt.
at RefCount.Increment(RefCount* )
at SharedPtr<V8Context>.=(SharedPtr<V8Context>* , SharedPtr<V8Context>* that)

at Microsoft.ClearScript.V8.V8ContextProxyImpl.~V8ContextProxyImpl()
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean A_0)
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose()
at Microsoft.ClearScript.V8.V8ScriptEngine.Dispose(Boolean disposing)
at Microsoft.ClearScript.ScriptEngine.Dispose()
at ClearScriptLoadTest.ClearScriptWrapper.Finalize() in c:\Users\xxxxxx\Doc
uments\Visual Studio 2013\Projects\ClearScriptLoadTest\ClearScriptLoadTest\Progr
am.cs:line 18

It works fine when dispose is deterministic .

regards
```
skpandey
```

New Post: Global window object

$
0
0
Is there some implementation of a decent browser DOM as well?

Source code checked in, #e9b6e92a0036fb2c033b6ecd14dc953bc36c2474

$
0
0
Added defensive code to make V8-related API objects resurrection-safe, fixing Issue #51.

Edited Issue: [FIXED] AccessViolationException while calling Dispose on V8ScriptEngine from a Finalizer [51]

$
0
0
Hi,
I am getting an AccessViolationException while calling V8ScriptEngine from a finalizer.
I can reproduce the issue with below code:
____________________________________________________________________________________
```
namespace ClearScriptLoadTest
{
public class ClearScriptWrapper
{
private Microsoft.ClearScript.V8.V8ScriptEngine v8Engine;
public ClearScriptWrapper()
{
this.v8Engine = new Microsoft.ClearScript.V8.V8ScriptEngine(Microsoft.ClearScript.V8.V8ScriptEngineFlags.None);
}
~ClearScriptWrapper()
{
Console.WriteLine("Finalizer called");
v8Engine.Dispose();
}
}


class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 1000000; i++)
{
ClearScriptWrapper csObj = new ClearScriptWrapper();
GC.Collect();
}
}
}
}

```

____________________________________________________________________________________

__Exception :__

Unhandled Exception: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory is corrupt.
at RefCount.Increment(RefCount* )
at SharedPtr<V8Context>.=(SharedPtr<V8Context>* , SharedPtr<V8Context>* that)

at Microsoft.ClearScript.V8.V8ContextProxyImpl.~V8ContextProxyImpl()
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean A_0)
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose()
at Microsoft.ClearScript.V8.V8ScriptEngine.Dispose(Boolean disposing)
at Microsoft.ClearScript.ScriptEngine.Dispose()
at ClearScriptLoadTest.ClearScriptWrapper.Finalize() in c:\Users\xxxxxx\Doc
uments\Visual Studio 2013\Projects\ClearScriptLoadTest\ClearScriptLoadTest\Progr
am.cs:line 18

It works fine when dispose is deterministic .

regards
```
skpandey
```

Commented Issue: [FIXED] AccessViolationException while calling Dispose on V8ScriptEngine from a Finalizer [51]

$
0
0
Hi,
I am getting an AccessViolationException while calling V8ScriptEngine from a finalizer.
I can reproduce the issue with below code:
____________________________________________________________________________________
```
namespace ClearScriptLoadTest
{
public class ClearScriptWrapper
{
private Microsoft.ClearScript.V8.V8ScriptEngine v8Engine;
public ClearScriptWrapper()
{
this.v8Engine = new Microsoft.ClearScript.V8.V8ScriptEngine(Microsoft.ClearScript.V8.V8ScriptEngineFlags.None);
}
~ClearScriptWrapper()
{
Console.WriteLine("Finalizer called");
v8Engine.Dispose();
}
}


class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 1000000; i++)
{
ClearScriptWrapper csObj = new ClearScriptWrapper();
GC.Collect();
}
}
}
}

```

____________________________________________________________________________________

__Exception :__

Unhandled Exception: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory is corrupt.
at RefCount.Increment(RefCount* )
at SharedPtr<V8Context>.=(SharedPtr<V8Context>* , SharedPtr<V8Context>* that)

at Microsoft.ClearScript.V8.V8ContextProxyImpl.~V8ContextProxyImpl()
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean A_0)
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose()
at Microsoft.ClearScript.V8.V8ScriptEngine.Dispose(Boolean disposing)
at Microsoft.ClearScript.ScriptEngine.Dispose()
at ClearScriptLoadTest.ClearScriptWrapper.Finalize() in c:\Users\xxxxxx\Doc
uments\Visual Studio 2013\Projects\ClearScriptLoadTest\ClearScriptLoadTest\Progr
am.cs:line 18

It works fine when dispose is deterministic .

regards
```
skpandey
```
Comments: Fix posted [here](https://clearscript.codeplex.com/SourceControl/changeset/e9b6e92a0036fb2c033b6ecd14dc953bc36c2474).

New Post: Global window object

New Post: Global window object

$
0
0
I meant DOM implementation that uses clearscript.

New Post: Global window object

$
0
0
It requires the script engine to call back to the host for all global property access, and that's a performance killer for V8, at least in scenarios that require fast access to global properties.
But that is what browsers do, I presume. How can it be more expensive than exposing host methods?
Viewing all 2297 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>