Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-1112] Fix the sourcemap handler script #242

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bbe08a9
Fix `gNewScriptHandlers` to replace old handlers
Domiii May 9, 2024
8763576
Merge branch 'master' of https://github.com/replayio/chromium-v8 into…
Domiii May 10, 2024
4cbd949
Undo `GetCreationContextChecked` workaround
Domiii May 10, 2024
3c1a8ff
Fix a "new script handler" bug and add exception logging
Domiii May 10, 2024
0383f69
WIP
Domiii May 14, 2024
3a14b26
WIP
Domiii May 14, 2024
ebc8601
Moving stuff around
Domiii May 16, 2024
c5edb0c
WIP
Domiii May 17, 2024
34dc194
Merge branch 'master' of https://github.com/replayio/chromium-v8 into…
Domiii May 19, 2024
9304a65
WIP
Domiii May 19, 2024
08d35d8
WIP
Domiii May 20, 2024
e908ad5
WIP: Moving sh*t ouf of `debug.cc`
Domiii May 21, 2024
4d29197
Merge branch 'master' of https://github.com/replayio/chromium-v8 into…
Domiii May 24, 2024
689fdb1
WIP
Domiii May 24, 2024
06b7f9a
Allow multiple `record-replay-internal` urls
Domiii May 24, 2024
3d83a37
Fixing things
Domiii May 24, 2024
a94e3d6
WIP
Domiii May 25, 2024
7606a96
WIP
Domiii May 25, 2024
6010428
Don't try to emit events when compiling the init script.
Domiii May 29, 2024
5a9dbb7
whoops
Domiii May 29, 2024
33e687e
whoops
Domiii May 29, 2024
cf49ce8
Don't register "internal Replay JS" scripts.
Domiii May 29, 2024
81969b7
Merge branch 'master' of https://github.com/replayio/chromium-v8 into…
Domiii May 31, 2024
6870fd1
Add missing `HandleScope` and improve exception handling when calling…
Domiii May 31, 2024
e390097
Fixing more errors
Domiii Jun 4, 2024
1905cbb
Merge branch 'master' of https://github.com/replayio/chromium-v8 into…
Domiii Jun 4, 2024
ea1ffeb
Merge branch 'master' of https://github.com/replayio/chromium-v8 into…
Domiii Jun 7, 2024
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
21 changes: 3 additions & 18 deletions src/api/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5191,26 +5191,11 @@ MaybeLocal<v8::Context> v8::Object::GetCreationContext() {
return MaybeLocal<v8::Context>();
}

extern "C" void V8RecordReplayGetDefaultContext(v8::Isolate* isolate, v8::Local<v8::Context>* cx);

Local<v8::Context> v8::Object::GetCreationContextChecked() {
Local<Context> context;
if (!GetCreationContext().ToLocal(&context)) {
// When recording/replaying we avoid crashing by falling back to the
// default context.
//
// See https://linear.app/replay/issue/TT-957
if (recordreplay::IsRecordingOrReplaying() && IsMainThread()) {
recordreplay::Print("Warning: GetCreationContextChecked missing context, substituting default context");
Isolate* isolate = Isolate::GetCurrent();
V8RecordReplayGetDefaultContext(isolate, &context);
} else {
CHECK(false);
}
}
//Utils::ApiCheck(GetCreationContext().ToLocal(&context),
// "v8::Object::GetCreationContextChecked",
// "No creation context available");
Utils::ApiCheck(GetCreationContext().ToLocal(&context),
Copy link
Author

Choose a reason for hiding this comment

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

Undo our workaround.

"v8::Object::GetCreationContextChecked",
"No creation context available");
return context;
}

Expand Down
19 changes: 12 additions & 7 deletions src/debug/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3712,8 +3712,9 @@ bool RecordReplayIsDivergentUserJSWithoutPause(
Script::cast(shared.script()));
}

typedef std::vector<std::pair<Eternal<Value>*, bool>> NewScriptHandlerVector;
static NewScriptHandlerVector* gNewScriptHandlers;
typedef std::pair<Eternal<Value>*, bool> NewScriptHandlerPair;
typedef std::unordered_map<std::string, NewScriptHandlerPair> NewScriptHandlerMap;
static NewScriptHandlerMap* gNewScriptHandlers;

extern "C" void V8RecordReplayEnterReplayCode();
extern "C" void V8RecordReplayExitReplayCode();
Expand Down Expand Up @@ -3796,8 +3797,8 @@ static void RecordReplayRegisterScript(Handle<Script> script) {

if (gNewScriptHandlers) {
for (auto entry : *gNewScriptHandlers) {
auto handlerEternalValue = entry.first;
auto disallowEvents = entry.second;
auto handlerEternalValue = entry.second.first;
auto disallowEvents = entry.second.second;

AutoMarkReplayCode amrc;
base::Optional<replayio::AutoDisallowEvents> disallow;
Expand Down Expand Up @@ -4332,12 +4333,16 @@ void FunctionCallbackRecordReplayAddNewScriptHandler(const FunctionCallbackInfo<

Isolate* v8isolate = callArgs.GetIsolate();
auto handler = new Eternal<Value>(v8isolate, callArgs[0]);
bool disallowEvents = callArgs.Length() >= 2 && callArgs[1]->IsTrue();
v8::String::Utf8Value scriptHandlerName(v8isolate, callArgs[1]);
bool disallowEvents = callArgs.Length() >= 3 && callArgs[2]->IsTrue();

if (!i::gNewScriptHandlers) {
i::gNewScriptHandlers = new i::NewScriptHandlerVector();
i::gNewScriptHandlers = new i::NewScriptHandlerMap();
}
i::gNewScriptHandlers->emplace_back(handler, disallowEvents);
i::gNewScriptHandlers->insert(std::make_pair<std::string, i::NewScriptHandlerPair>(
std::string(*scriptHandlerName),
i::NewScriptHandlerPair(handler, disallowEvents)
));
}

void FunctionCallbackRecordReplayGetScriptSource(const FunctionCallbackInfo<Value>& callArgs) {
Expand Down