diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/SvgImageCreatorImp.java b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/SvgImageCreatorImp.java index 1793f3e396e37692f45615d067d5b4122fe4745d..e100e2a9e405f19883dafaa756f50f4d31a1522f 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/SvgImageCreatorImp.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/SvgImageCreatorImp.java @@ -29,8 +29,7 @@ public class SvgImageCreatorImp implements SvgImageCreator { private SwfSlidesGenerationProgressNotifier notifier; private long imageTagThreshold; private long pathsThreshold; - private String convTimeout = "60s"; - private int WAIT_FOR_SEC = 60; + private int convPdfToSvgTimeout = 60; private String BLANK_SVG; @Override @@ -64,14 +63,14 @@ public class SvgImageCreatorImp implements SvgImageCreator { dest = imagePresentationDir.getAbsolutePath() + File.separator + "slide-1.pdf"; NuProcessBuilder convertImgToSvg = new NuProcessBuilder( - Arrays.asList("timeout", convTimeout, "convert", source, "-auto-orient", dest)); + Arrays.asList("timeout", convPdfToSvgTimeout + "s", "convert", source, "-auto-orient", dest)); Png2SvgConversionHandler pHandler = new Png2SvgConversionHandler(); convertImgToSvg.setProcessListener(pHandler); NuProcess process = convertImgToSvg.start(); try { - process.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS); + process.waitFor(convPdfToSvgTimeout, TimeUnit.SECONDS); done = true; } catch (InterruptedException e) { done = false; @@ -97,7 +96,7 @@ public class SvgImageCreatorImp implements SvgImageCreator { NuProcess process = convertPdfToSvg.start(); try { - process.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS); + process.waitFor(convPdfToSvgTimeout, TimeUnit.SECONDS); done = true; } catch (InterruptedException e) { log.error("Interrupted Exception while generating SVG slides {}", pres.getName(), e); @@ -159,20 +158,20 @@ public class SvgImageCreatorImp implements SvgImageCreator { convertPdfToPng.setProcessListener(pngHandler); NuProcess pngProcess = convertPdfToPng.start(); try { - pngProcess.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS); + pngProcess.waitFor(convPdfToSvgTimeout, TimeUnit.SECONDS); } catch (InterruptedException e) { log.error("Interrupted Exception while generating PNG image {}", pres.getName(), e); } // Step 2: Convert a PNG image to SVG - NuProcessBuilder convertPngToSvg = new NuProcessBuilder(Arrays.asList("timeout", convTimeout, "convert", + NuProcessBuilder convertPngToSvg = new NuProcessBuilder(Arrays.asList("timeout", convPdfToSvgTimeout + "s", "convert", tempPng.getAbsolutePath(), destsvg.getAbsolutePath())); Png2SvgConversionHandler svgHandler = new Png2SvgConversionHandler(); convertPngToSvg.setProcessListener(svgHandler); NuProcess svgProcess = convertPngToSvg.start(); try { - svgProcess.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS); + svgProcess.waitFor(convPdfToSvgTimeout, TimeUnit.SECONDS); } catch (InterruptedException e) { log.error("Interrupted Exception while generating SVG image {}", pres.getName(), e); } @@ -184,7 +183,7 @@ public class SvgImageCreatorImp implements SvgImageCreator { // Step 3: Add SVG namespace to the destionation file // Check : https://phabricator.wikimedia.org/T43174 - NuProcessBuilder addNameSpaceToSVG = new NuProcessBuilder(Arrays.asList("timeout", convTimeout, + NuProcessBuilder addNameSpaceToSVG = new NuProcessBuilder(Arrays.asList("timeout", convPdfToSvgTimeout + "s", "/bin/sh", "-c", "sed -i " + "'4s|>| xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.2\">|' " @@ -194,7 +193,7 @@ public class SvgImageCreatorImp implements SvgImageCreator { addNameSpaceToSVG.setProcessListener(namespaceHandler); NuProcess namespaceProcess = addNameSpaceToSVG.start(); try { - namespaceProcess.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS); + namespaceProcess.waitFor(convPdfToSvgTimeout, TimeUnit.SECONDS); } catch (InterruptedException e) { log.error("Interrupted Exception while adding SVG namespace {}", pres.getName(), e); } @@ -232,7 +231,7 @@ public class SvgImageCreatorImp implements SvgImageCreator { rawCommand += " && cat " + destFile; rawCommand += " | egrep 'data:image/png;base64|<path' | sed 's/ / /g' | cut -d' ' -f 1 | sort | uniq -cw 2"; } - return new NuProcessBuilder(Arrays.asList("timeout", convTimeout, "/bin/sh", "-c", rawCommand)); + return new NuProcessBuilder(Arrays.asList("timeout", convPdfToSvgTimeout + "s", "/bin/sh", "-c", rawCommand)); } private File determineSvgImagesDirectory(File presentationFile) { @@ -278,4 +277,9 @@ public class SvgImageCreatorImp implements SvgImageCreator { SwfSlidesGenerationProgressNotifier notifier) { this.notifier = notifier; } + + public void setConvPdfToSvgTimeout(int convPdfToSvgTimeout) { + this.convPdfToSvgTimeout = convPdfToSvgTimeout; + } + } diff --git a/bigbluebutton-web/grails-app/conf/bigbluebutton.properties b/bigbluebutton-web/grails-app/conf/bigbluebutton.properties index c618b764ca5798d6cc080cf19675610bf5215939..150fc25a7bf6470af63d0aef99398da9e8f3799d 100755 --- a/bigbluebutton-web/grails-app/conf/bigbluebutton.properties +++ b/bigbluebutton-web/grails-app/conf/bigbluebutton.properties @@ -98,6 +98,11 @@ numConversionThreads=5 #------------------------------------ numFileProcessorThreads=2 +#------------------------------------ +# Timeout(secs) to wait for pdf to svg conversion (time for each page) +#------------------------------------ +svgConversionTimeout=60 + #------------------------------------ # Timeout(secs) to wait for conversion script execution #------------------------------------ diff --git a/bigbluebutton-web/grails-app/conf/spring/doc-conversion.xml b/bigbluebutton-web/grails-app/conf/spring/doc-conversion.xml index c5ab9192081adac7a47c4828f264c6f94a9f9f72..b98c13fa43e6e7db0888c1a665c3a5559876a9fa 100755 --- a/bigbluebutton-web/grails-app/conf/spring/doc-conversion.xml +++ b/bigbluebutton-web/grails-app/conf/spring/doc-conversion.xml @@ -86,6 +86,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. <property name="imageTagThreshold" value="${imageTagThreshold}"/> <property name="pathsThreshold" value="${placementsThreshold}"/> <property name="blankSvg" value="${BLANK_SVG}"/> + <property name="convPdfToSvgTimeout" value="${svgConversionTimeout}"/> </bean> <bean id="generatedSlidesInfoHelper" class="org.bigbluebutton.presentation.GeneratedSlidesInfoHelperImp"/>