Skip to content

webview ipc memory leak #2706

Closed
Closed

Description

@kidwm

I use this method to keep checking if the webview has a textfield onfocus and show the virtual keyboard, but it would cause the renderer process continue to eat more and more memory.

Tested with v0.31.2

index.html

<webview id="browser" preload="./browser.js" disablewebsecurity src="about:blank" />

browser.js

var ipc = require('ipc');
var textField = function(target) {
    return target.nodeName == 'INPUT' && ['text', 'password', 'color', 'email', 'number', 'search', 'tel', 'url'].indexOf(target.type) >= 0 || target.nodeName == 'TEXTAREA';
};

ipc.on('keyboard', function(){
    if (document.hasFocus()) {
        if (textField(document.activeElement))
            ipc.sendToHost('showKeyboard');
        else
            ipc.sendToHost('hideKeyboard');
    }
});

app.js

var request = function() {
    window.requestAnimationFrame(request);
    webview.send('keyboard');
};

window.requestAnimationFrame(request);

Activity

  1. kidwm commented on Sep 30, 2015

    @kidwm
    Author

    @zcbenz Awesome! 趙大人請受我一拜 Orz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions