GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Playwright - add java sources to a captured Playwright trace by antonfilichkin · Pull Request #1450 · allure-framework/allure-java Conversation
|
| if (!AllurePlaywrightConfig.shouldEmbedTraceSources()) { | ||
| return false; | ||
| } | ||
| if (Objects.isNull(System.getenv(PLAYWRIGHT_JAVA_SRC))) { |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| ZipEntry entry; | ||
| while ((entry = zis.getNextEntry()) != null) { | ||
| final String name = entry.getName(); | ||
| final byte[] content = readAll(zis); |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| if (stored) { | ||
| final CRC32 crc = new CRC32(); | ||
| crc.update(content); | ||
| outEntry.setMethod(ZipEntry.STORED); |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
- 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.
0461ca9 to
ffc9e1b
Compare
… name Playwright 1.64 stores trace sources as src/<sha1>.java instead of resources/src@<sha1>.txt.
|
@antonfilichkin Could you please take a look at failing test? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Requested changes must be addressed to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Playwright: support embedding Java sources in captured traces
There was an error while loading. Please reload this page.