AnsweredAssumed Answered

Web Viewer javascript executes differently under some circumstances in FM17 than in FM16, or after leaving and re-entering browse mode

Question asked by kupietz on Oct 16, 2018
Latest reply on Oct 30, 2018 by kupietz

Here's a really obscure bug. Javascript works differently in web viewers in FileMaker 16 Advanced and earlier and in FIleMaker 17 Advanced (v17.0.2.205)

 

OS: MacOS X 10.12.6

 

The attached file is a demo I created that uses Mozilla's PDF.js framework to display a PDF from a container field in a web viewer. (This technique sidesteps several major technical limitations of FM's interactive container type.)

 

I have added sequential alerts throughout the javascript just so you can see where execution fails.

 

Steps to replicate:

1.) Open the attached file in FileMaker 16 or earlier on OS X 12.6. As the web viewer draws, dismiss the successive alerts that come up. After all alerts are done (roughly 12-15 alerts), the sample PDF displays in the web viewer. Then you can close the file.
2.) Open the attached file in FileMaker 17 Advanced on OS X 12.6.

 

Expected behavior:

Same as described for FMA 16 in #1 above.

 

Actual behavior in FM 17:

3) After file opens, as web viewer draws, alerts come up to indicate javascript progress.

4.) Alerts suddenly stop appearing and javascript aborts after Alert #6. PDF does not display.

5.) Make a simple edit to the field "jsscripts", say by adding a whitespace to a comment line, and exit the record to refresh the web viewer.
6.) As web viewer redraws, alerts come up to indicate javascript progress.

7.) Alerts suddenly stop appearing and javascript aborts after Alert #6. PDF does not display.

 

Workaround:

8.) Now, enter layout mode by hitting CMD-L.

9.) Immediately re-enter browse mode by hitting CMD-B.

10.) Now, the Alerts complete all the way to the end of the series, and the PDF displays in the web viewer as expected.

11.) From here on in, the web viewer will update properly and behave as expected, until you close the file.

 

By tracking where the alerts stop firing, I think I've narrowed it down to a javascript promise that fails to return (line 66398, "page.render(renderContext).then(function() {"). Obviously, it's tempting to blame this on a webkit bug, except that the file functions exactly as expected in FM16 and earlier, or in FM17 after simply entering layout mode and re-entering browse mode, and yet, without doing that workaround, even updating a field the web viewer was dependent on, triggering a complete recalculation of the WV source, failed to get the javascript to execute correctly. After a single switch to layout mode and back, it functions exactly as expected, every single time, until the file is closed. When you close and then reopen the file in FileMaker 17, the problems recur again until you switch out of and back into browse mode again.

 

EDIT, 10/17: I just tried using a Set Web Viewer script step to get the Web Viewer to manually update. I tried all three available options: reset, reload, and Go To Url with the proper data url. None of these work if you have not left end re-entered Browse mode yet. They all work afterwards. Same for Refresh Object.

Outcomes