@@ -1080,6 +1080,59 @@ impl StaticExporter {
10801080 data. split_once ( "," ) . map ( |d| d. 1 . to_string ( ) )
10811081 }
10821082
1083+ /// Get Firefox preferences optimized for CI environments.
1084+ ///
1085+ /// These preferences force software rendering and enable WebGL in headless
1086+ /// mode to work around graphics/WebGL issues in CI environments.
1087+ #[ cfg( feature = "geckodriver" ) ]
1088+ fn get_firefox_ci_preferences ( ) -> serde_json:: Map < String , serde_json:: Value > {
1089+ let mut prefs = JsonMap :: new ( ) ;
1090+
1091+ // Force software rendering and enable WebGL in headless mode
1092+ prefs. insert (
1093+ "layers.acceleration.disabled" . to_string ( ) ,
1094+ serde_json:: json!( true ) ,
1095+ ) ;
1096+ prefs. insert ( "gfx.webrender.all" . to_string ( ) , serde_json:: json!( false ) ) ;
1097+ prefs. insert (
1098+ "gfx.webrender.software" . to_string ( ) ,
1099+ serde_json:: json!( true ) ,
1100+ ) ;
1101+ prefs. insert ( "webgl.disabled" . to_string ( ) , serde_json:: json!( false ) ) ;
1102+ prefs. insert ( "webgl.force-enabled" . to_string ( ) , serde_json:: json!( true ) ) ;
1103+ prefs. insert ( "webgl.enable-webgl2" . to_string ( ) , serde_json:: json!( true ) ) ;
1104+
1105+ // Force software WebGL implementation
1106+ prefs. insert (
1107+ "webgl.software-rendering" . to_string ( ) ,
1108+ serde_json:: json!( true ) ,
1109+ ) ;
1110+ prefs. insert (
1111+ "webgl.software-rendering.force" . to_string ( ) ,
1112+ serde_json:: json!( true ) ,
1113+ ) ;
1114+
1115+ // Disable hardware acceleration completely
1116+ prefs. insert (
1117+ "gfx.canvas.azure.accelerated" . to_string ( ) ,
1118+ serde_json:: json!( false ) ,
1119+ ) ;
1120+ prefs. insert (
1121+ "gfx.canvas.azure.accelerated-layers" . to_string ( ) ,
1122+ serde_json:: json!( false ) ,
1123+ ) ;
1124+ prefs. insert (
1125+ "gfx.content.azure.backends" . to_string ( ) ,
1126+ serde_json:: json!( "cairo" ) ,
1127+ ) ;
1128+
1129+ // Force software rendering for all graphics
1130+ prefs. insert ( "gfx.2d.force-enabled" . to_string ( ) , serde_json:: json!( true ) ) ;
1131+ prefs. insert ( "gfx.2d.force-software" . to_string ( ) , serde_json:: json!( true ) ) ;
1132+
1133+ prefs
1134+ }
1135+
10831136 fn build_webdriver_caps ( & self ) -> Result < Capabilities > {
10841137 // Define browser capabilities
10851138 let mut caps = JsonMap :: new ( ) ;
@@ -1101,6 +1154,14 @@ impl StaticExporter {
11011154 debug ! ( "Added Firefox binary capability: {firefox_path}" ) ;
11021155 }
11031156
1157+ // Add Firefox-specific preferences for CI environments
1158+ #[ cfg( feature = "geckodriver" ) ]
1159+ {
1160+ let prefs = Self :: get_firefox_ci_preferences ( ) ;
1161+ browser_opts. insert ( "prefs" . to_string ( ) , serde_json:: json!( prefs) ) ;
1162+ debug ! ( "Added Firefox preferences for CI compatibility" ) ;
1163+ }
1164+
11041165 caps. insert (
11051166 "browserName" . to_string ( ) ,
11061167 serde_json:: json!( get_browser_name( ) ) ,
0 commit comments