GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Playwright - add java sources to a captured Playwright trace by antonfilichkin · Pull Request #1450 · allure-framework/allure-java

Conversation

@antonfilichkin

@antonfilichkin antonfilichkin commented Sep 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Context

Closes #1452

Allows attaching java sources to Playwright traces.

Allure only configures Playwright traces to include screenshots and snapshots via

new Tracing.StartOptions()
    .setScreenshots(true)
    .setSnapshots(true)

Playwright allows including java sources by setting PLAYWRIGHT_JAVA_SRC and configuring tracing via

new Tracing.StartOptions()
    .setSources(true)

The problem:

  1. Playwright provides trace as .zip binary
  2. Playwright doesn't have mechanism to suppress synthetic frames from trace, it only handles its own ones. But with Allure enabled - frame 0 is always synthetic AspectJ-weaving glue inserted by AllurePlaywrightAspect, not the real caller - making Trace Viewer's Source tab useless.
  3. Playwright handles trace building on it's binary side

The idea is to add configurable option to allow Allure rewrite sources and remove it's own synthetic frames
Implementation idea:

  • Add allure.playwright.trace.sources (default false) to opt into embedding sources in the trace.
  • Add TraceStackSourceTrimmer, which rewrites the trace.stacks entry in place: it resolves the first file-backed frame in each stack, falling back to stripping the leading run of recognizable AspectJ/Playwright weaving frames when no frame resolves. Fails open on any error, leaving the trace attached unchanged. With some short-circuits to disable zip/json processing - I.e. binary blobs, sources path not set.

Trace examples (both with sources)
Screenshot 2026-09-21 at 12 07 30
npx playwright show-trace trace-after.zip
trace-before.zip
trace-after.zip

Checklist

  • Sign Allure CLA
  • Provide unit tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@antonfilichkin
feat(playwright): make trace source embedding configurable and trim A…
3d80220
…spectJ frames from trace stacks

Playwright's Tracing.StartOptions#setSources embeds a stack per action, but
frame 0 is always synthetic AspectJ-weaving glue inserted by
AllurePlaywrightAspect, not the real caller - making Trace Viewer's Source
tab useless without this.

- Add allure.playwright.trace.sources (default false) to opt into embedding
  sources in the trace.
- Add TraceStackSourceTrimmer, which rewrites the trace.stacks entry in
  place: it resolves the first file-backed frame in each stack, falling
  back to stripping the leading run of recognizable AspectJ/Playwright
  weaving frames when no frame resolves. Fails open on any error, leaving
  the trace attached unchanged.
- Declare the module's new compile-time-only dependency on Gson in
  module-info.java.
@antonfilichkin antonfilichkin mentioned this pull request Oct 8, 2026
Playwright: support embedding Java sources in captured traces #1452
Open
@baev
baev requested review from a team and andrcuns and removed request for a team November 2, 2026 17:19
@antonfilichkin
Merge branch 'main' into feat/playwright-trace-sources-flag
181a7cc
andrcuns
andrcuns requested changes Nov 4, 2026
View reviewed changes

@andrcuns andrcuns left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the submission @antonfilichkin

My java is very rusty (almost non existent at this point 😅 ) but an agent review found a few issues, could you please check?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread allure-playwright/src/main/java/io/qameta/allure/playwright/AllurePlaywright.java Outdated
if (!AllurePlaywrightConfig.shouldEmbedTraceSources()) {
return false;
}
if (Objects.isNull(System.getenv(PLAYWRIGHT_JAVA_SRC))) {

@andrcuns andrcuns Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

[P2] Do not disable valid per-instance Playwright source configuration

Playwright also accepts source roots through Playwright.create(new Playwright.CreateOptions().setEnv(Map.of("PLAYWRIGHT_JAVA_SRC", sourceRoot))); the variable does not have to exist in the JVM's process environment. With this supported configuration and allure.playwright.trace.sources=true, this check returns false, so startTracing() sets sources=false and skips trimming.

I reproduced the mismatch against Playwright 1.62.0: its real StackTraceCollector.createFromEnv() accepts the instance configuration, while the Allure helper passes StartOptions.sources=false. The new real-trace test uses this same setEnv() mechanism, but starts tracing directly rather than through AllurePlaywright.startTracing(), so it does not cover this failure.

Please let the opt-in property enable source embedding without requiring System.getenv() to contain the source roots, and cover the per-instance configuration through the public helper.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

antonfilichkin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@antonfilichkin antonfilichkin Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed in ffc9e1b. I dropped the System.getenv check, so allure.playwright.trace.sources=true now passes setSources(true) by itself. Playwright reads PLAYWRIGHT_JAVA_SRC from CreateOptions.setEnv() first and falls back to the process environment. If it's set in neither, no stacks are recorded, the trace has no trace.stacks, and the trimmer leaves it untouched. AllurePlaywrightEmbedSourcesTest now covers this through AllurePlaywright.startTracing() with setEnv(). It checks that sources are embedded and that frame 0 resolves to the test class.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread allure-playwright/src/main/java/io/qameta/allure/playwright/TraceStackSourceTrimmer.java Outdated
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
final String name = entry.getName();
final byte[] content = readAll(zis);

@andrcuns andrcuns Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

[P2] Stream unchanged entries instead of buffering every decompressed resource

This reads every ZIP entry fully into heap, including screenshots and captured network response bodies, even though only trace.stacks needs transformation. ByteArrayOutputStream grows an unbounded backing array and toByteArray() then allocates another full copy. The resources/ handling below does not skip this allocation.

I reproduced an uncaught OutOfMemoryError in TraceStackSourceTrimmer.readAll() using a 49,237-byte ZIP containing a 48 MiB resource and a valid trace.stacks entry, with a 64 MiB child-JVM heap. Neither this class nor DefaultTraceSession.stop() catches that error, so trace diagnostics can disrupt test execution instead of failing open and attaching the original archive.

Please copy unchanged entries with bounded memory, buffering only the stack JSON. Preserving their original compressed payloads would also avoid unnecessary decompression.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

antonfilichkin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@antonfilichkin antonfilichkin Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed in ffc9e1b. The trimmer now edits the archive through the JDK zip filesystem (FileSystems.newFileSystem(trace)). Only trace.stacks is read and replaced. The other entries are copied with their original compressed payloads, so screenshots and network bodies are no longer decompressed into memory. It still fails open: the zip filesystem writes the new archive to a temp file and swaps it in only on success, and any IOException or RuntimeException leaves the original trace as it was.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread allure-playwright/src/main/java/io/qameta/allure/playwright/TraceStackSourceTrimmer.java Outdated
if (stored) {
final CRC32 crc = new CRC32();
crc.update(content);
outEntry.setMethod(ZipEntry.STORED);

@andrcuns andrcuns Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

[P2] Preserve compression for text resources

Every resources/ entry reaches this branch, but that directory contains compressible HTML, JavaScript, JSON response bodies, and embedded Java sources, not only already-compressed screenshots. Writing all of them as STORED can substantially increase the trace attachment size.

Running this trimmer on the PR's own trace-before.zip increased the archive from 17,968 to 28,554 bytes (about 59%). Its HTML resource alone expanded from 2,301 compressed bytes to 6,639 stored bytes. Larger or text-heavy traces will incur unnecessary attachment storage, transfer, and loading costs.

Please preserve unchanged entries' compressed payloads, or at least retain compression for compressible resources rather than treating the entire resources/ directory as incompressible binary data.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

antonfilichkin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@antonfilichkin antonfilichkin Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed by the same change. Unchanged entries keep their original compression method and compressed bytes, and the resources/ → STORED special case is gone. shouldPreserveCompressionOfUnchangedEntries checks that a compressed HTML resource keeps its exact compressed size and that a STORED binary entry stays STORED.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@andrcuns andrcuns added the pr:improvement Change that improves some user experience but can't be considered as a new feature label Nov 4, 2026
@antonfilichkin
fix(playwright): address review feedback on trace source embedding
ffc9e1b
- Don't require PLAYWRIGHT_JAVA_SRC in the process environment: Playwright
  also accepts it per instance via CreateOptions.setEnv(), so the
  allure.playwright.trace.sources property alone now enables sources.
- Rewrite only trace.stacks via the JDK zip filesystem; all other entries
  are copied with their original compressed payloads instead of being
  fully buffered in memory and re-written as STORED.
- Cover per-instance configuration through AllurePlaywright.startTracing()
  and check that unchanged entries keep their compression.
@antonfilichkin
antonfilichkin force-pushed the feat/playwright-trace-sources-flag branch from 0461ca9 to ffc9e1b Compare November 6, 2026 06:30
antonfilichkin added 2 commits November 6, 2026 09:28
@antonfilichkin
Merge remote-tracking branch 'upstream/main' into feat/playwright-tra…
59a32fa
…ce-sources-flag
@antonfilichkin
test(playwright): check embedded source by content, not archive entry…
4ce6bf3
… name

Playwright 1.64 stores trace sources as src/<sha1>.java instead of
resources/src@<sha1>.txt.
@andrcuns

andrcuns commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@antonfilichkin Could you please take a look at failing test?

antonfilichkin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@andrcuns andrcuns andrcuns requested changes

Requested changes must be addressed to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

pr:improvement Change that improves some user experience but can't be considered as a new feature

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Playwright: support embedding Java sources in captured traces

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@antonfilichkin @andrcuns
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.