Skip to content

Conversation

wcandillon
Copy link
Contributor

@wcandillon wcandillon commented Sep 22, 2025

No description provided.

@wcandillon wcandillon requested a review from Copilot September 23, 2025 10:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for explicit resource management in the Skia package by implementing the Symbol.dispose pattern and updating the TypeScript configuration to ES2024. The changes enable automatic resource cleanup using the using keyword instead of manual dispose() calls.

  • Updates TypeScript configuration to ES2024 with explicit resource management support
  • Implements Symbol.dispose pattern across Skia classes and refactors dispose methods
  • Updates test files to use the using keyword for automatic resource management

Reviewed Changes

Copilot reviewed 56 out of 59 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/skia/tsconfig.json Updates TypeScript target to ES2024 and adds ES2024 lib support
packages/skia/src/skia/web/*.ts Implements Symbol.dispose pattern and removes standalone dispose methods
packages/skia/src/skia/web/Host.ts Adds default Symbol.dispose implementation in BaseHostObject
packages/skia/src/skia/types/JsiInstance.ts Extends interface with Disposable
test files Updates tests to use using keyword for automatic resource management
configuration files Adds Babel plugin and updates dependencies for explicit resource management

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

getLineMetrics(): LineMetrics[] {
return this.ref.getLineMetrics();
}

Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dispose() method calls this[Symbol.dispose]() but there's no [Symbol.dispose]() method defined in this class. This will result in a runtime error when dispose() is called.

Suggested change
[Symbol.dispose]() {
// Implement cleanup logic here if needed.
// For now, this is a no-op to prevent runtime errors.
}

Copilot uses AI. Check for mistakes.

constructor(CanvasKit: CanvasKit, ref: FontMgr) {
super(CanvasKit, ref, "FontMgr");
}

Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dispose() method calls this[Symbol.dispose]() but there's no [Symbol.dispose]() method defined in this class. This will result in a runtime error when dispose() is called.

Suggested change
[Symbol.dispose]() {
// No-op or add cleanup logic here if needed
}

Copilot uses AI. Check for mistakes.

// Check for dispose symbol as last resort
static const auto disposeSymbol = jsi::PropNameID::forSymbol(
runtime,
eval(runtime, "Symbol.for('Symbol.dispose');").getSymbol(runtime));
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Symbol.for('Symbol.dispose') instead of the actual Symbol.dispose symbol. The correct symbol should be accessed via Symbol.dispose, not Symbol.for('Symbol.dispose').

Suggested change
eval(runtime, "Symbol.for('Symbol.dispose');").getSymbol(runtime));
eval(runtime, "Symbol.dispose").getSymbol(runtime));

Copilot uses AI. Check for mistakes.

*/
fromBytes(bytes: Uint8Array) {
return new JsiSkData(this.CanvasKit, bytes);
return new JsiSkData(this.CanvasKit, bytes as unknown as ArrayBuffer);
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The double type assertion as unknown as ArrayBuffer suggests a type mismatch. Consider fixing the underlying type issue instead of using a double assertion, which bypasses TypeScript's type safety.

Suggested change
return new JsiSkData(this.CanvasKit, bytes as unknown as ArrayBuffer);
// Ensure we pass only the relevant ArrayBuffer portion
const arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
return new JsiSkData(this.CanvasKit, arrayBuffer);

Copilot uses AI. Check for mistakes.

@wcandillon wcandillon merged commit a87b15d into Shopify:main Sep 23, 2025
1 check passed
Copy link
Contributor

🎉 This PR is included in version 2.2.19 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

1 participant