Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sad-parents-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/react": patch
---

Disable MTS HMR functionality temporarily to address stability issues. This is a temporary fix while we work on a more robust solution.
2 changes: 1 addition & 1 deletion packages/react/runtime/__test__/snapshotPatch.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ describe('DEV_ONLY_addSnapshot', () => {
});
});

describe('DEV_ONLY_RegisterWorklet', () => {
describe.skip('DEV_ONLY_RegisterWorklet', () => {
beforeEach(() => {
initGlobalSnapshotPatch();
});
Expand Down
20 changes: 10 additions & 10 deletions packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ export function snapshotPatchApply(snapshotPatch: SnapshotPatch): void {
}
break;
}
case SnapshotOperation.DEV_ONLY_RegisterWorklet: {
// HMR-related
if (__DEV__) {
const hash: string = snapshotPatch[++i];
const fnStr: string = snapshotPatch[++i];
const fn = evaluate<(ctx: SnapshotInstance) => FiberElement[]>(fnStr);
registerWorklet('main-thread', hash, fn);
}
break;
}
// case SnapshotOperation.DEV_ONLY_RegisterWorklet: {
// // HMR-related
// if (__DEV__) {
// const hash: string = snapshotPatch[++i];
// const fnStr: string = snapshotPatch[++i];
// const fn = evaluate<(ctx: SnapshotInstance) => FiberElement[]>(fnStr);
// registerWorklet('main-thread', hash, fn);
// }
// break;
// }
}
}
}
Expand Down
34 changes: 19 additions & 15 deletions packages/react/runtime/src/worklet/hmr.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { SnapshotOperation, __globalSnapshotPatch } from '../lifecycle/patch/snapshotPatch.js';
// import { __globalSnapshotPatch } from '../lifecycle/patch/snapshotPatch.js';

const workletHashSet: Set<string> = /* @__PURE__ */ new Set();
// const workletHashSet: Set<string> = /* @__PURE__ */ new Set();

/* v8 ignore start */
/**
* @internal
*/
function registerWorkletOnBackground(_type: string, hash: string, fn: Function) {
if (workletHashSet.has(hash)) {
return;
}
workletHashSet.add(hash);
if (__globalSnapshotPatch) {
__globalSnapshotPatch.push(
SnapshotOperation.DEV_ONLY_RegisterWorklet,
hash,
// We use `Function.prototype.toString` to serialize the function for Lepus.
fn.toString(),
);
}
// disable hmr until bugs are fixed
// TODO: re-enable hmr or change a way to impl it; also need to fix the test case DEV_ONLY_RegisterWorklet
function registerWorkletOnBackground(_type: string, _hash: string, _fn: Function) {
// if (workletHashSet.has(hash)) {
// return;
// }
// workletHashSet.add(hash);
// if (__globalSnapshotPatch) {
// __globalSnapshotPatch.push(
// SnapshotOperation.DEV_ONLY_RegisterWorklet,
// hash,
// // We use `Function.prototype.toString` to serialize the function for Lepus.
// fn.toString(),
// );
// }
}
/* v8 ignore stop */

export { registerWorkletOnBackground };
Loading