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

Chromium: capture png size error #19563

Closed
stacey-gammon opened this issue May 30, 2018 · 12 comments · Fixed by #20061
Closed

Chromium: capture png size error #19563

stacey-gammon opened this issue May 30, 2018 · 12 comments · Fixed by #20061
Labels
bug Fixes for quality problems that affect the customer experience (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@stacey-gammon
Copy link
Contributor

stacey-gammon commented May 30, 2018

Sometimes, so far only reproducible on jenkins agents, the chromium driver will capture a screenshot of the wrong dimensions.

The code which seems to be at fault is this:

          const { data } = await Page.captureScreenshot({
            clip: {
              ...screenshotClip,
              scale: 1
            }
          });
          this._logger.debug(`Captured screenshot clip ${JSON.stringify(screenshotClip)}`);
          return data;
        }, this._logger);

The data coming back is not of the size expected, though the check that fails is a little later down the pipeline. When I added some extra code above, in an attempt to verify that the issue is indeed within Page.captureScreenshot, the error failed to manifest. There only reasons I can think for this happening is:

  • The bug is flaky so maybe I just didn't try to reproduce long enough (unlikely because I was running tests 10x and hit it pretty consistently before the change, not once even after 20x runs after the change).
  • We are manipulating the data somewhere after it gets returned from this function, but before the place where it failed the size check later on in the code.
  • There is a reference to the data object kept around inside the chromium client which is manipulating the stream after it's returned (seems unlikely).
  • RxJs is somehow manipulating, or not streaming, all of the data at the time of the second size check?? If this was the case however, the bug should still have manifested with the initial size check.

The code in question is this:

 const screenshots$ = screenshotClips$.pipe(
   // *****
   // The code above is what gets executed inside the captureScreenshotFn.
   // *****
    mergeMap(clip => captureScreenshotFn(clip), (clip, data) => ({ clip, data }), 1)
  );

  // when we take the screenshots we don't have to scale the rects
  // but the PNGs don't know about the zoom, so we have to scale them
  const screenshotPngRects$ = screenshots$.pipe(
    map(({ data, clip }) => {
      // At this point we don't care about the offset - the screenshots have been taken.
      // We need to adjust the x & y values so they all are adjusted for the top-left most
      // clip being at 0, 0.
      const x = clip.x - outputClip.x;
      const y = clip.y - outputClip.y;

      const scaledScreenshotRects = scaleRect(
        {
          height: clip.height,
          width: clip.width,
          x,
          y,
        },
        zoom
      );
      return {
        data,
        rectangle: scaledScreenshotRects,
      };
    })
  );

   // *****
   // The code in $combine is what checks the dimensions of each screenshot and verifies they are
   // of the right size.
   // *****
  const scaledOutputRects = scaleRect(outputClip, zoom);
  return screenshotPngRects$
    .pipe(
      toArray(),
      switchMap<Screenshot[], string>((screenshots: Screenshot[]) =>
        $combine(
          screenshots,
          {
            height: scaledOutputRects.height,
            width: scaledOutputRects.width,
          },
          logger
        )
      )
    )
    .toPromise<string>();
}

Options for next steps to debug:

  • Run a linux VM locally to try to repro outside of jenkins agent
  • Run on jenkins, turn the snapshot tests back on, use the actual dimensions of the data instead of our expected dimensions and view the report to hopefully get more information as to what is going on.
  • Simplify code, reduce the number of abstractions, and see if we can either glean more information.
  • Replace chrome-remote-interface with puppeteer, as the later is supported by Google.
  • Move the data -> png conversion up sooner, which seems to alleviate hitting the bug, but probably just hides it, not fixes it.
@stacey-gammon stacey-gammon added bug Fixes for quality problems that affect the customer experience :Sharing (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead labels May 30, 2018
@tylersmalley
Copy link
Contributor

For this issue, let's be sure to restore the Chromium tests in x-pack/scripts/functional_tests.js

@stacey-gammon
Copy link
Contributor Author

This seems to be an issue where the captureScreenshot function returns an image that is not scaled correctly to the zoom factor.

What is interesting is that in preserve layout mode, the zoom setting doesn't seem to work right anyway (see #20091).

Although we probably shouldn't get rid of it completely because the default zoom setting looks more pixelated in chrome than in phantom: #20089

Here is also some more debug output copied over from #19871

failure output:

14:42:35        │ proc  [kibana]   log   [14:42:35.730] [debug][reporting][screenshots] taking screenshots
14:42:35        │ proc  [kibana]   log   [14:42:35.730] [debug][chromium-driver-factory][reporting] elementPosition is not null, boundingClientRect is {"top":0,"left":0,"width":1060,"height":404}
14:42:35        │ proc  [kibana]   log   [14:42:35.731] [debug][chromium-driver-factory][reporting] screenshotStitcher with zoom of 2 and max of 1950 and outputClips of {"x":0,"y":0,"height":404,"width":1060}
14:42:35        │ proc  [kibana]   log   [14:42:35.732] [debug][chromium-driver-factory][reporting] rows calculated by: Math.ceil(404 / 975) || 1
14:42:35        │ proc  [kibana]   log   [14:42:35.732] [debug][chromium-driver-factory][reporting] rows is 1
14:42:35        │ proc  [kibana]   log   [14:42:35.733] [debug][chromium-driver-factory][reporting] get clips with dimensions: {"x":0,"y":0,"height":404,"width":1060}
14:42:35        │ proc  [kibana]   log   [14:42:35.733] [debug][chromium-driver-factory][reporting] Screenshot stitcher: Yielding x 0 and y 0 and w: 975 and h 404
14:42:35        │ proc  [kibana]   log   [14:42:35.733] [debug][chromium-driver-factory][reporting] height calculated by: 0 === 1 - 1 ? 404 - (0 * 975) : 975
14:42:35        │ proc  [kibana]   log   [14:42:35.734] [debug][chromium-driver-factory][reporting] get clips with dimensions: {"x":0,"y":0,"height":404,"width":1060}
14:42:35        │ proc  [kibana]   log   [14:42:35.734] [debug][chromium-driver-factory][reporting] Screenshot stitcher: Yielding x 975 and y 0 and w: 85 and h 404
14:42:35        │ proc  [kibana]   log   [14:42:35.735] [debug][chromium-driver-factory][reporting] height calculated by: 0 === 1 - 1 ? 404 - (0 * 975) : 975
14:42:35        │ proc  [kibana]   log   [14:42:35.924] [debug][chromium-driver-factory][reporting] captured screenshot clip {"x":0,"y":0,"width":975,"height":404}
14:42:35        │ proc  [kibana]   log   [14:42:35.924] [debug][chromium-driver-factory][reporting] Creating capture dimensions for clip {"x":0,"y":0,"width":975,"height":404}
14:42:35        │ proc  [kibana]   log   [14:42:35.980] [debug][chromium-driver-factory][reporting] captured screenshot clip {"x":975,"y":0,"width":85,"height":404}
14:42:35        │ proc  [kibana]   log   [14:42:35.980] [debug][chromium-driver-factory][reporting] Creating capture dimensions for clip {"x":975,"y":0,"width":85,"height":404}
14:42:36        │ proc  [kibana]   log   [14:42:36.010] [debug][chromium-driver-factory][reporting] Output dimensions is {"x":0,"y":0,"width":2120,"height":808}
14:42:36        │ proc  [kibana]   log   [14:42:36.010] [debug][chromium-driver-factory][reporting] Input png w: 170 and h: 404
14:42:36        │ proc  [kibana]   log   [14:42:36.010] [debug][chromium-driver-factory][reporting] Creating output png with {"x":1950,"y":0,"width":170,"height":808}
14:42:36        │ proc  [kibana]   log   [14:42:36.030] [debug][esqueue][reporting][worker] jilsq1z103we2ad6bd8gb6mw - Failure occurred on job jilssiqk03we2ad6bd93twb9: Error: bitblt reading outside image
14:42:36        │ proc  [kibana]     at Function.PNG.bitblt (/var/lib/jenkins/workspace/elastic+kibana+pull-request+multijob-x-pack/install/kibana/node_modules/pngjs/lib/png.js:131:11)
14:42:36        │ proc  [kibana]     at exports.PNG.PNG.bitblt (/var/lib/jenkins/workspace/elastic+kibana+pull-request+multijob-x-pack/install/kibana/node_modules/pngjs/lib/png.js:150:7)

Success:

6:03:41        │ proc  [kibana]   log   [16:03:41.742] [debug][reporting][screenshots] rendering is complete
16:03:41        │ proc  [kibana]   log   [16:03:41.753] [debug][reporting][screenshots] timeRange from 2018-06-19T15:48:34Z to 2018-06-19T16:03:34Z
16:03:41        │ proc  [kibana]   log   [16:03:41.810] [debug][reporting][screenshots] taking screenshots
16:03:41        │ proc  [kibana]   log   [16:03:41.811] [debug][chromium-driver-factory][reporting] elementPosition is not null, boundingClientRect is {"top":0,"left":0,"width":1060,"height":404}
16:03:41        │ proc  [kibana]   log   [16:03:41.811] [debug][chromium-driver-factory][reporting] screenshotStitcher with zoom of 2 and max of 1950 and outputClips of {"x":0,"y":0,"height":404,"width":1060}
16:03:41        │ proc  [kibana]   log   [16:03:41.813] [debug][chromium-driver-factory][reporting] rows calculated by: Math.ceil(404 / 975) || 1
16:03:41        │ proc  [kibana]   log   [16:03:41.813] [debug][chromium-driver-factory][reporting] rows is 1
16:03:41        │ proc  [kibana]   log   [16:03:41.813] [debug][chromium-driver-factory][reporting] get clips with dimensions: {"x":0,"y":0,"height":404,"width":1060}
16:03:41        │ proc  [kibana]   log   [16:03:41.813] [debug][chromium-driver-factory][reporting] Screenshot stitcher: Yielding x 0 and y 0 and w: 975 and h 404
16:03:41        │ proc  [kibana]   log   [16:03:41.814] [debug][chromium-driver-factory][reporting] height calculated by: 0 === 1 - 1 ? 404 - (0 * 975) : 975
16:03:41        │ proc  [kibana]   log   [16:03:41.814] [debug][chromium-driver-factory][reporting] get clips with dimensions: {"x":0,"y":0,"height":404,"width":1060}
16:03:41        │ proc  [kibana]   log   [16:03:41.815] [debug][chromium-driver-factory][reporting] Screenshot stitcher: Yielding x 975 and y 0 and w: 85 and h 404
16:03:41        │ proc  [kibana]   log   [16:03:41.815] [debug][chromium-driver-factory][reporting] height calculated by: 0 === 1 - 1 ? 404 - (0 * 975) : 975
16:03:41        │ proc  [kibana]   log   [16:03:41.816] [debug][license][xpack] Calling [data] Elasticsearch _xpack API. Polling frequency: 30001
16:03:41        │ proc  [kibana]   log   [16:03:41.968] [debug][chromium-driver-factory][reporting] captured screenshot clip {"x":0,"y":0,"width":975,"height":404}
16:03:41        │ proc  [kibana]   log   [16:03:41.969] [debug][chromium-driver-factory][reporting] Creating capture dimensions for clip {"x":0,"y":0,"width":975,"height":404}
16:03:42        │ proc  [kibana]   log   [16:03:42.062] [debug][chromium-driver-factory][reporting] captured screenshot clip {"x":975,"y":0,"width":85,"height":404}
16:03:42        │ proc  [kibana]   log   [16:03:42.063] [debug][chromium-driver-factory][reporting] Creating capture dimensions for clip {"x":975,"y":0,"width":85,"height":404}
16:03:42        │ proc  [kibana]   log   [16:03:42.093] [debug][chromium-driver-factory][reporting] Output dimensions is {"x":0,"y":0,"width":2120,"height":808}
16:03:42        │ proc  [kibana]   log   [16:03:42.093] [debug][chromium-driver-factory][reporting] Input png w: 170 and h: 808
16:03:42        │ proc  [kibana]   log   [16:03:42.093] [debug][chromium-driver-factory][reporting] Creating output png with {"x":1950,"y":0,"width":170,"height":808}
16:03:42        │ proc  [kibana]   log   [16:03:42.125] [debug][license][xpack] Calling [monitoring] Elasticsearch _xpack API. Polling frequency: 30001
16:03:42        │ proc  [kibana]   log   [16:03:42.236] [debug][chromium-driver-factory][reporting] Output dimensions is {"x":0,"y":0,"width":2120,"height":808}
16:03:42        │ proc  [kibana]   log   [16:03:42.236] [debug][chromium-driver-factory][reporting] Input png w: 1950 and h: 808
16:03:42        │ proc  [kibana]   log   [16:03:42.236] [debug][chromium-driver-factory][reporting] Creating output png with {"x":0,"y":0,"width":1950,"height":808}
16:03:42        │ proc  [kibana]   log   [16:03:42.582] [debug][kibana-monitoring][monitoring-ui] Fetching data from kibana collector
16:03:42        │ proc  [kibana]   log   [16:03:42.583] [debug][kibana-monitoring][monitoring-ui] Fetching data from kibana_stats collector
16:03:42        │ proc  [kibana]   log   [16:03:42.583] [debug][kibana-monitoring][monitoring-ui] Fetching data from kibana_settings collector
16:03:42        │ proc  [kibana]   log   [16:03:42.584] [debug][kibana-monitoring][monitoring-ui] Fetching data from reporting_stats collector
16:03:42        │ proc  [kibana]   log   [16:03:42.591] [debug][plugin] Checking Elasticsearch version
16:03:42        │ proc  [kibana]   log   [16:03:42.596] [debug][reporting][screenshots] screenshot took 781ms
16:03:42        │ proc  [kibana]   log   [16:03:42.706] [debug][kibana-monitoring][monitoring-ui] not sending [kibana_settings] monitoring document because [undefined] is null or invalid.
16:03:42        │ proc  [kibana]   log   [16:03:42.731] [debug][kibana-monitoring][monitoring-ui] Uploading bulk stats payload to the local cluster
16:03:43        │ proc  [kibana]   log   [16:03:43.212] [debug][esqueue][reporting][worker] jilvmdmm0lk0056de57n8kxd - Completed job jilvosqq0lk0056de55z6p48
16:03:43        │ proc  [kibana]   log   [16:03:43.229] [debug][reporting][worker] PDF: Worker completed: (jilvosqq0lk0056de55z6p48)

@stacey-gammon
Copy link
Contributor Author

Synced with @kobelb to go over some of the ci output. Looks like from run to run on ci the requested reporting dimensions change slightly, so this could factor into the flakiness (e.g. it might only show up when the dimensions are x/y).

It still seems like a report with the exact same dimensions of x/y passed, so even when the dimensions are the exact same, sometimes it passes, sometimes it fails.

More things to try:

  • Run chromium tests multiple times on the same agent.
  • Run only reporting tests to make comparisons easier (was difficult to wade through all the logs to compare output to output - almost looked like some runs were passing even though they didn't complete, but I wasn't sure if it was a comparison error).
  • Set max clip dimension to something very small in an attempt to trigger the failure more frequently - this means we'd be taking many more clips.
  • Could also try a retry on the Page.captureScreenshot call if the dimensions captured are not what we expect, although this should only be done as a last resort as first it would be good to nail down exactly when this error occurs, and try to figure out why, before throwing in a blind retry.

@stacey-gammon
Copy link
Contributor Author

Recent test run included multiple passes and one failure, on the same agent, and the same values. This seems to indicate it's an issue with Page.captureScreenshot than the data or logic we are doing ourselves.

Fail:

16:47:42                    │ proc  [kibana]   log   [16:47:42.950] [debug][chromium-driver-factory][reporting] Captured screenshot clip {"height":441,"width":975,"x":0,"y":0}
16:47:42                    │ proc  [kibana]   log   [16:47:42.994] [debug][chromium-driver-factory][reporting] Captured screenshot clip {"height":441,"width":27,"x":975,"y":0}
16:47:42                    │ proc  [kibana]   log   [16:47:42.994] [debug][chromium-driver-factory][reporting] Combining screenshot clips into final, scaled output dimension of {"height":882,"width":2004}
16:47:43                    │ proc  [kibana]   log   [16:47:43.167] [error][chromium-driver-factory][reporting] Screenshot captured with width:54 and height: 441) is not of expected width: 54 and height: 882
16:47:43                    │ proc  [kibana]   log   [16:47:43.178] [debug][esqueue][reporting][worker] jivxbh6f054ladd59bfofrkw - Failure occurred on job jivxbze8054ladd59b97emp6: Error: Screenshot captured with width:54 and height: 441) is not of expected width: 54 and height: 882

Passed 4 or 5 times before hitting that above error with this output:

16:41:55        │ proc  [kibana]   log   [16:41:55.038] [debug][chromium-driver-factory][reporting] Captured screenshot clip {"height":441,"width":975,"x":0,"y":0}
16:41:55        │ proc  [kibana]   log   [16:41:55.087] [debug][chromium-driver-factory][reporting] Captured screenshot clip {"height":441,"width":27,"x":975,"y":0}
16:41:55        │ proc  [kibana]   log   [16:41:55.087] [debug][chromium-driver-factory][reporting] Combining screenshot clips into final, scaled output dimension of {"height":882,"width":2004}
16:41:55        │ proc  [kibana]   log   [16:41:55.264] [debug][chromium-driver-factory][reporting] Output dimensions is {"height":882,"width":2004}
16:41:55        │ proc  [kibana]   log   [16:41:55.265] [debug][chromium-driver-factory][reporting] Input png w: 54 and h: 882

@stacey-gammon
Copy link
Contributor Author

Latest information indicates that it isn't because the page is not set to the right scale factor because the first screenshot captured is of the correct size.

18:44:48    │ proc  [kibana]   log   [18:44:48.110] [debug][reporting][screenshots] taking screenshots
18:44:48    │ proc  [kibana]   log   [18:44:48.110] [debug][chromium-driver-factory][reporting] elementPosition is not null, boundingClientRect is {"top":0,"left":0,"width":1002,"height":441}
18:44:48    │ proc  [kibana]   log   [18:44:48.111] [debug][chromium-driver-factory][reporting] Capturing screenshot clip {"height":441,"width":975,"x":0,"y":0}
18:44:48    │ proc  [kibana]   log   [18:44:48.551] [debug][chromium-driver-factory][reporting] Captured screenshot clip {"height":441,"width":975,"x":0,"y":0}
18:44:48    │ proc  [kibana]   log   [18:44:48.553] [debug][chromium-driver-factory][reporting] Capturing screenshot clip {"height":441,"width":27,"x":975,"y":0}
18:44:48    │ proc  [kibana]   log   [18:44:48.604] [debug][chromium-driver-factory][reporting] Captured screenshot clip {"height":441,"width":27,"x":975,"y":0}
18:44:48    │ proc  [kibana]   log   [18:44:48.607] [debug][esqueue][reporting][worker] jiw1i0fp03qsaa1e3d6u6oun - Failure occurred on job jiw1ilh703qsaa1e3dbazorc: Error: Screenshot captured with width:54 and height: 441) is not of expected width: 54 and height: 882
18:44:48    │ proc  [kibana]     at /var/lib/jenkins/workspace/elastic+kibana+pull-request+multijob-x-

Will see what happens if I throw in a retry

@stacey-gammon
Copy link
Contributor Author

Latest experimentation shows that the error fails to manifest when I added a retry. There is no good explanation for why this should be the case since nothing changed prior to the Page.captureScreenshot call which was not returning the correct data size. To be clear - the retry didn't fix the problem, rather once I added the retry code the error never showed up in the first place.

@stacey-gammon stacey-gammon changed the title Chromium reports sometimes fail in screenshotStitcher when calling png.bitblt Chromium: capture png size error Jul 28, 2018
@stacey-gammon
Copy link
Contributor Author

Hit twice. Once here: https://kibana-ci.elastic.co/job/elastic+kibana+pull-request+multijob-x-pack/6162/consoleFull | #21520

and #21468 (comment) too (passed subsequent run with no changes).

09:57:31    │ proc  [ftr]        └-> multiple jobs posted
09:57:31    │ proc  [ftr]          └-> "before each" hook: global before each
09:57:31    │ proc  [kibana]   log   [09:57:31.522] [warning][deprecation][reporting] The title should be provided with the job generation request. Please use Kibana to regenerate your URLs. This functionality will be removed with the next major version.
09:57:31    │ proc  [kibana]   log   [09:57:31.583] [warning][deprecation][reporting] The relativeUrl should be provided with the job generation request. Please use Kibana to regenerate your URLs. This functionality will be removed with the next major version.
09:57:31    │ info  [o.e.c.m.MetaDataCreateIndexService] [] [.reporting-2018.07.29] creating index, cause [api], templates [], shards [1]/[1], mappings [esqueue]
09:57:31    │ info  [o.e.c.r.a.AllocationService] [] updating number_of_replicas to [0] for indices [.reporting-2018.07.29]
09:57:31    │ proc  [kibana]   log   [09:57:31.834] [warning][deprecation][reporting] The title should be provided with the job generation request. Please use Kibana to regenerate your URLs. This functionality will be removed with the next major version.
09:57:31    │ proc  [kibana]   log   [09:57:31.898] [warning][deprecation][reporting] The relativeUrl should be provided with the job generation request. Please use Kibana to regenerate your URLs. This functionality will be removed with the next major version.
09:57:32    │ info  [o.e.c.m.MetaDataMappingService] [] [.reporting-2018.07.29/GOROGZpjTOiO_49j5ZBMSQ] update_mapping [esqueue]
09:57:57    │ proc  [kibana]   log   [09:57:57.057] [error][chromium-driver-factory][reporting] Capture PNG size error. Please visit https://github.com/elastic/kibana/issues/19563 to report this error. Screenshot captured of size 54x441 was not of expected size 54x882
09:57:57    │ proc  [kibana]   log   [09:57:57.059] [error][chromium-driver-factory][reporting] Capture PNG size error. Please visit https://github.com/elastic/kibana/issues/19563 to report this error. Screenshot captured of size 54x441 was not of expected size 54x882
09:57:57    │ proc  [kibana]   log   [09:57:57.060] [error][chromium-driver-factory][reporting] Trying again...
09:57:57    │ proc  [kibana]   log   [09:57:57.360] [error][chromium-driver-factory][reporting] Capture PNG size error. Please visit https://github.com/elastic/kibana/issues/19563 to report this error. Screenshot captured of size 54x441 was not of expected size 54x882
09:57:57    │ proc  [kibana]   log   [09:57:57.361] [error][chromium-driver-factory][reporting] Capture PNG size error. Please visit https://github.com/elastic/kibana/issues/19563 to report this error. Screenshot captured of size 54x441 was not of expected size 54x882
09:57:57    │ proc  [kibana]   log   [09:57:57.361] [error][chromium-driver-factory][reporting] Trying again...
09:57:57    │ proc  [kibana]   log   [09:57:57.653] [error][chromium-driver-factory][reporting] Capture PNG size error. Please visit https://github.com/elastic/kibana/issues/19563 to report this error. Screenshot captured of size 1002x441 was not of expected size 1950x882
09:57:57    │ proc  [kibana]   log   [09:57:57.653] [error][chromium-driver-factory][reporting] Capture PNG size error. Please visit https://github.com/elastic/kibana/issues/19563 to report this error. Screenshot captured of size 1002x441 was not of expected size 1950x882
09:57:57    │ proc  [kibana]   log   [09:57:57.654] [error][chromium-driver-factory][reporting] Trying again...
09:57:57    │ proc  [kibana]   log   [09:57:57.890] [error][chromium-driver-factory][reporting] Capture PNG size error. Please visit https://github.com/elastic/kibana/issues/19563 to report this error. Screenshot captured of size 54x441 was not of expected size 54x882
09:57:59    │ proc  [ftr]        └- ✖ fail: "chromium BWC report generation urls 6_2 multiple jobs posted"
09:57:59    │ proc  [ftr]        │        Error: expected 500 to equal 200
09:57:59    │ proc  [ftr]        │         at Assertion.assert (node_modules/expect.js/index.js:96:13)
09:57:59    │ proc  [ftr]        │         at Assertion.be.Assertion.equal (node_modules/expect.js/index.js:216:10)
09:57:59    │ proc  [ftr]        │         at Assertion.(anonymous function) [as be] (node_modules/expect.js/index.js:69:24)
09:57:59    │ proc  [ftr]        │         at Object.waitForJobToFinish (test/reporting/services/reporting_api.js:39:29)
09:57:59    │ proc  [ftr]        │         at <anonymous>

Looks like the retry is not sufficient. 😭

@chrisdavies
Copy link
Contributor

If we detect this, before throwing the exception, we could have Chromium print a full PDF to some debugging / log location.

@stacey-gammon mentioned puppeteer when we chatted, and after looking at the code yesterday, I think it would be a relatively simple drop in. Puppeteer even has a method for capturing a specific element, which is what we are doing manually with that failing clip logic. Puppeteer also supports alternatives to base64 encoding (buffers and files). So, it may be worth a bit of tinkering.

@kobelb
Copy link
Contributor

kobelb commented Aug 2, 2018

Puppeteer even has a method for capturing a specific element, which is what we are doing manually with that failing clip logic. Puppeteer also supports alternatives to base64 encoding (buffers and files). So, it may be worth a bit of tinkering.

You'll want to ensure that Puppeteer has the ability to provide a custom build of Chromium, when this was initially written this was a limitation. There were also lacking APIs for some of the operations that we performed. Also puppeteer/puppeteer#477 is still outstanding, which is what we're overcoming by doing our own screenshot stitching.

@chrisdavies
Copy link
Contributor

@kobelb is right.

Also, their support for binary / file is just a thin wrapper around the underlying base64 string, so it's not actually a win: https://github.com/GoogleChrome/puppeteer/blob/25632133e2683c613c97d9088968c48e3c07a086/lib/Page.js#L859-L862

@stacey-gammon
Copy link
Contributor Author

I attempted to spit out the pdf using the png's width/height instead of our expected width/height. It didn't seem to give me any data at all.

See here I changed

png.bitblt(output, 0, 0, rectangle.width, rectangle.height, rectangle.x, rectangle.y) to
png.bitblt(output, 0, 0, png.width, png.height, rectangle.x, rectangle.y);

I also turned snapshot reporting tests on so I could see the output. This is what I got:

screen shot 2018-08-01 at 9 23 22 pm

Not very helpful.

I think the next best steps are:

  1. Sync up with @jbudz next week to get chromium building on docker.
  2. Bump the checksum so we build a newer version of chromium
  3. See if the bug is reproducible then.

We really need to do 1 and 2 anyway, and if it fixes the bug, then we can avoid spending any more cycles on it.

I also attempted to switch more code over to typescript but ran into quite a few issues, I think which upgrading to a newer chromium will also help. I'll file them in a separate issue to keep track.

@stacey-gammon
Copy link
Contributor Author

Seems to be fixed automagically with new chromium builds, here: #21788

@timroes timroes removed enhancement New value added to drive a business result Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Sep 13, 2018
@timroes timroes added Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed PR sent :Sharing labels Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
5 participants