Taritsyn / DartSassHost

.NET wrapper around the Dart Sass.
MIT License
21 stars 3 forks source link

Bug #11

Closed koma-tompit closed 9 months ago

koma-tompit commented 1 year ago

Creating a new SassCompiler using the 7.3.5 version of the V8 Engine switcher results in an exception when attempting to use the compiler (or even view it's properties in the debugger).

The problem appears to be present in both .net6 and .net7 on the MacOS. The application closes due to a hard fault (no exception thrown, force closes the debugger as well). The console output states only

Fatal error in , line 0 Check failed: 12 == (*__error()).

FailureMessage Object: 0x7ff7baf9f590

The problem is reproducible by running the webcompiler here: https://github.com/excubo-ag/WebCompiler as is, compiling any .sass file.

Taritsyn commented 1 year ago

Hello!

As I understand it, this issue duplicates an issue #4 “Unable to use DartSassHost in local dotnet tool”.

JasonXtreme commented 1 year ago

Hi, I am unsure of whether it is the same bug, as the symptoms are slightly different. I get the same result from running either from the app in VS in debugger mode, as an executable or as a dotnet tool. Switching the js engine to jint resolved this problem, but caused the minifier to die as the css output had minus characters ("-") of an incompatible encoding, and the minifier could not parse them. Finally, Chakra got it working on both MacOS and Windows with the same build.

I referenced the webcompiler due to it being my entrypoint into the bug(running from source), but it would seem the problem is reproducible without it as well.

Taritsyn commented 1 year ago

Actually this error is not directly related to the Dart Sass Host or JavaScript Engine Switcher libraries. This error occurs somewhere at the level of the V8, ClearScript or .NET.

At the beginning of this year, in issue tracker of the ClearScript project, I described in detail how to reproduce this error. It is still relevant for the ClearScript 7.3.6 and .NET 7.0.1. After installing the .NET Runtime 5.0.17, error disappears.

Taritsyn commented 1 year ago

Hello, Matija!

Switching the js engine to jint resolved this problem, but caused the minifier to die as the css output had minus characters ("-") of an incompatible encoding, and the minifier could not parse them.

I would be interested to take a look at a fragment of Sass or SCSS code leading to such an error.

koma-tompit commented 1 year ago

Right, sorry, the two people talking to you are me, I somehow switched accounts without noticing.

The chunk of scss is rather large, and I have no time to sample for a minimal viable example. The error appears in translates (where there is a negative translation, say -50% by x or y).

The source that I produced the errors with is here, if you can find the time (I linked a commit that builds, as others may not, nevermind the changelog): https://git.tompit.com/Connected/Connected.Components/commit/663103f1d79abc7aeabc705933a81baab24545a9

The root file is located under src/Connected.Components/Styles/Connected.Components.scss. Compiling it with excubo.webcompiler using

dotnet webcompiler ./Styles/Connected.Components.scss -c excubowebcompiler.json

from the folder src/Connected.Components/ should give you all the errors I described.

To reiterate:

FailureMessage Object: 0x7ff7baf9f590

and forcefully shuts down, even while debugging, running the line 

using (var compiler = new DartSassHost.SassCompiler(JsEngineFactory.Instance)) { compile_result = compiler.CompileFile(file, tmp_output_file, file, options); }


 from the SassCompiler class in the excubo source.

- The excubo.webcompiler, compiled from source with the V8JsEngineFactory swapped out for the JintJsEngineFactory in [./Compile/SassCompiler.cs](https://github.com/excubo-ag/WebCompiler/blob/main/WebCompiler/Compile/JsEngineFactory.cs) produces a seemingly ok build of the css, but only with minification turned to false. A deeper look at the compiled .css reveals that not all minus characters are the same, and even Dreamweaver points them out as errors in the css.

- A build from source using ChakraCore in the same place as Jint above appears to work fine, both for compilation and minification.
Taritsyn commented 1 year ago

Hello, Matija!

To reiterate:

  • Stock excubo.webcompiler, the tool from nuget, outputs

Fatal error in , line 0 Check failed: 12 == (*__error()).

FailureMessage Object: 0x7ff7baf9f590

A similar error message is now displayed in my old example without the Dart Sass Host or JavaScript Engine Switcher libraries.

The source that I produced the errors with is here, if you can find the time (I linked a commit that builds, as others may not, nevermind the changelog): https://git.tompit.com/Connected/Connected.Components/commit/663103f1d79abc7aeabc705933a81baab24545a9

The root file is located under src/Connected.Components/Styles/Connected.Components.scss. Compiling it with excubo.webcompiler using

dotnet webcompiler ./Styles/Connected.Components.scss -c excubowebcompiler.json

from the folder src/Connected.Components/ should give you all the errors I described.

My compilation and minification was completed without errors. Only I used .NET 7 and JavaScriptEngineSwitcher.Jint 3.20.8 Preview.