fix: macos, load multi dylib instances (#8731)
Multiple dylib instances will cause some global instances to be invalid. eg. lazy_static objects in rust side, will be created more than once. Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
		
							parent
							
								
									a4565bf0da
								
							
						
					
					
						commit
						901505e8be
					
				@ -117,9 +117,13 @@ class PlatformFFI {
 | 
				
			|||||||
            ? DynamicLibrary.open('librustdesk.so')
 | 
					            ? DynamicLibrary.open('librustdesk.so')
 | 
				
			||||||
            : isWindows
 | 
					            : isWindows
 | 
				
			||||||
                ? DynamicLibrary.open('librustdesk.dll')
 | 
					                ? DynamicLibrary.open('librustdesk.dll')
 | 
				
			||||||
                : isMacOS
 | 
					                :
 | 
				
			||||||
                    ? DynamicLibrary.open("liblibrustdesk.dylib")
 | 
					                // Use executable itself as the dynamic library for MacOS.
 | 
				
			||||||
                    : DynamicLibrary.process();
 | 
					                // Multiple dylib instances will cause some global instances to be invalid.
 | 
				
			||||||
 | 
					                // eg. `lazy_static` objects in rust side, will be created more than once, which is not expected.
 | 
				
			||||||
 | 
					                //
 | 
				
			||||||
 | 
					                // isMacOS? DynamicLibrary.open("liblibrustdesk.dylib") :
 | 
				
			||||||
 | 
					                DynamicLibrary.process();
 | 
				
			||||||
    debugPrint('initializing FFI $_appType');
 | 
					    debugPrint('initializing FFI $_appType');
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      _session_get_rgba = dylib.lookupFunction<F3Dart, F3>("session_get_rgba");
 | 
					      _session_get_rgba = dylib.lookupFunction<F3Dart, F3>("session_get_rgba");
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user