mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 834414 - Free the local refs in GeckoThread's long-running run method to prevent leaks. r=cpeterson
This commit is contained in:
parent
92884bc973
commit
444a38b5ac
@ -31,7 +31,7 @@ public class GeckoThread extends Thread implements GeckoEventListener {
|
||||
|
||||
private static LaunchState sLaunchState = LaunchState.Launching;
|
||||
|
||||
private final Intent mIntent;
|
||||
private Intent mIntent;
|
||||
private final String mUri;
|
||||
|
||||
GeckoThread(Intent intent, String uri) {
|
||||
@ -41,8 +41,44 @@ public class GeckoThread extends Thread implements GeckoEventListener {
|
||||
GeckoAppShell.getEventDispatcher().registerEventListener("Gecko:Ready", this);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
private String initGeckoEnvironment() {
|
||||
// At some point while loading the gecko libs our default locale gets set
|
||||
// so just save it to locale here and reset it as default after the join
|
||||
Locale locale = Locale.getDefault();
|
||||
|
||||
GeckoApp app = GeckoApp.mAppContext;
|
||||
String resourcePath = app.getApplication().getPackageResourcePath();
|
||||
GeckoAppShell.setupGeckoEnvironment(app);
|
||||
GeckoAppShell.loadSQLiteLibs(app, resourcePath);
|
||||
GeckoAppShell.loadNSSLibs(app, resourcePath);
|
||||
GeckoAppShell.loadGeckoLibs(resourcePath);
|
||||
|
||||
Locale.setDefault(locale);
|
||||
|
||||
Resources res = app.getBaseContext().getResources();
|
||||
Configuration config = res.getConfiguration();
|
||||
config.locale = locale;
|
||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||
|
||||
return resourcePath;
|
||||
}
|
||||
|
||||
private String getTypeFromAction(String action) {
|
||||
if (action != null && action.startsWith(GeckoApp.ACTION_WEBAPP_PREFIX)) {
|
||||
return "-webapp";
|
||||
}
|
||||
if (GeckoApp.ACTION_BOOKMARK.equals(action)) {
|
||||
return "-bookmark";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String addCustomProfileArg(String args) {
|
||||
String profile = GeckoApp.sIsUsingCustomProfile ? "" : (" -P " + GeckoApp.mAppContext.getProfile().getName());
|
||||
return (args != null ? args : "") + profile;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Here we start the GfxInfo thread, which will query OpenGL
|
||||
// system information for Gecko. This must be done early enough that the data will be
|
||||
// ready by the time it's needed to initialize the LayerManager (it takes about 100 ms
|
||||
@ -52,46 +88,17 @@ public class GeckoThread extends Thread implements GeckoEventListener {
|
||||
GeckoAppShell.sGfxInfoThread = new GfxInfoThread();
|
||||
GeckoAppShell.sGfxInfoThread.start();
|
||||
|
||||
final GeckoApp app = GeckoApp.mAppContext;
|
||||
|
||||
// At some point while loading the gecko libs our default locale gets set
|
||||
// so just save it to locale here and reset it as default after the join
|
||||
Locale locale = Locale.getDefault();
|
||||
|
||||
String resourcePath = app.getApplication().getPackageResourcePath();
|
||||
GeckoAppShell.setupGeckoEnvironment(app);
|
||||
GeckoAppShell.loadSQLiteLibs(app, resourcePath);
|
||||
GeckoAppShell.loadNSSLibs(app, resourcePath);
|
||||
GeckoAppShell.loadGeckoLibs(resourcePath);
|
||||
|
||||
Locale.setDefault(locale);
|
||||
Resources res = app.getBaseContext().getResources();
|
||||
Configuration config = res.getConfiguration();
|
||||
config.locale = locale;
|
||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||
String path = initGeckoEnvironment();
|
||||
|
||||
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - runGecko");
|
||||
|
||||
// find the right intent type
|
||||
final String action = mIntent.getAction();
|
||||
String type = null;
|
||||
|
||||
if (action != null && action.startsWith(GeckoApp.ACTION_WEBAPP_PREFIX))
|
||||
type = "-webapp";
|
||||
else if (GeckoApp.ACTION_BOOKMARK.equals(action))
|
||||
type = "-bookmark";
|
||||
|
||||
String args = mIntent.getStringExtra("args");
|
||||
|
||||
String profile = GeckoApp.sIsUsingCustomProfile ? "" : (" -P " + app.getProfile().getName());
|
||||
args = (args != null ? args : "") + profile;
|
||||
String args = addCustomProfileArg(mIntent.getStringExtra("args"));
|
||||
String type = getTypeFromAction(mIntent.getAction());
|
||||
mIntent = null;
|
||||
|
||||
// and then fire us up
|
||||
Log.i(LOGTAG, "RunGecko - args = " + args);
|
||||
GeckoAppShell.runGecko(app.getApplication().getPackageResourcePath(),
|
||||
args,
|
||||
mUri,
|
||||
type);
|
||||
GeckoAppShell.runGecko(path, args, mUri, type);
|
||||
}
|
||||
|
||||
public void handleMessage(String event, JSONObject message) {
|
||||
|
Loading…
Reference in New Issue
Block a user